annotate loader/dmo/DMO_VideoDecoder.c @ 28921:62f0032e736a

Get rid of pointless preprocessor condition indirection and use ARCH_X86 directly instead of CAN_COMPILE_X86_ASM.
author diego
date Sun, 15 Mar 2009 10:01:02 +0000
parents f20a11161e62
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
1 /********************************************************
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
2
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
3 DirectShow Video decoder implementation
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
4 Copyright 2000 Eugene Kuznetsov (divx@euro.ru)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
5
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
6 *********************************************************/
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
7 #include "config.h"
22607
b99edbf76db4 Use explicit path for headers from the dshow/ subdirectory.
diego
parents: 22186
diff changeset
8 #include "dshow/guids.h"
b99edbf76db4 Use explicit path for headers from the dshow/ subdirectory.
diego
parents: 22186
diff changeset
9 #include "dshow/interfaces.h"
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
10 #include "registry.h"
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
11 #ifdef WIN32_LOADER
26544
f20a11161e62 Use consistent #include paths without "../".
diego
parents: 26104
diff changeset
12 #include "ldt_keeper.h"
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
13 #endif
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
14
22607
b99edbf76db4 Use explicit path for headers from the dshow/ subdirectory.
diego
parents: 22186
diff changeset
15 #include "dshow/libwin32.h"
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
16 #include "DMO_Filter.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
17
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
18 #include "DMO_VideoDecoder.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
19
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24392
diff changeset
20 struct DMO_VideoDecoder
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
21 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
22 IVideoDecoder iv;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
23
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
24 DMO_Filter* m_pDMO_Filter;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
25 AM_MEDIA_TYPE m_sOurType, m_sDestType;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
26 VIDEOINFOHEADER* m_sVhdr;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
27 VIDEOINFOHEADER* m_sVhdr2;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
28 int m_Caps;//CAPS m_Caps; // capabilities of DirectShow decoder
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
29 int m_iLastQuality; // remember last quality as integer
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
30 int m_iMinBuffers;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
31 int m_iMaxAuto;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
32 };
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
33
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
34 //#include "DMO_VideoDecoder.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
35
26544
f20a11161e62 Use consistent #include paths without "../".
diego
parents: 26104
diff changeset
36 #include "wine/winerror.h"
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
37
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
38 #include <unistd.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
39 #include <fcntl.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
40 #include <errno.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
41 #include <sys/types.h>
26104
e5bce92eb572 Replace __MINGW32__ preprocessor check with proper HAVE_SYS_MMAN_H check.
diego
parents: 25794
diff changeset
42 #ifdef HAVE_SYS_MMAN_H
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
43 #include <sys/mman.h>
9978
11cee15b1a8f last mingw32 support patch by Sascha Sommer
alex
parents: 9967
diff changeset
44 #endif
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
45 #include <stdio.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
46 #include <stdlib.h> // labs
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
47
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
48 // strcmp((const char*)info.dll,...) is used instead of (... == ...)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
49 // so Arpi could use char* pointer in his simplified DMO_VideoDecoder class
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
50
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
51 #define false 0
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
52 #define true 1
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
53
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
54
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
55 //int DMO_VideoDecoder_GetCapabilities(DMO_VideoDecoder *this){return this->m_Caps;}
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
56
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24392
diff changeset
57 typedef struct ct ct;
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
58
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24392
diff changeset
59 struct ct {
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
60 fourcc_t fcc;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
61 unsigned int bits;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
62 const GUID* subtype;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
63 int cap;
15574
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
64 char *name;
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
65 };
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
66
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
67 static ct check[] = {
15574
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
68 { fccI420, 12, &MEDIASUBTYPE_I420, CAP_I420, NULL },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
69 { fccYV12, 12, &MEDIASUBTYPE_YV12, CAP_YV12, NULL },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
70 { fccYUY2, 16, &MEDIASUBTYPE_YUY2, CAP_YUY2, NULL },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
71 { fccUYVY, 16, &MEDIASUBTYPE_UYVY, CAP_UYVY, NULL },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
72 { fccYVYU, 16, &MEDIASUBTYPE_YVYU, CAP_YVYU, NULL },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
73 { fccIYUV, 24, &MEDIASUBTYPE_IYUV, CAP_IYUV, NULL },
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
74
15574
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
75 { 8, 8, &MEDIASUBTYPE_RGB8, CAP_NONE, "RGB8" },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
76 { 15, 16, &MEDIASUBTYPE_RGB555, CAP_NONE, "RGB555" },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
77 { 16, 16, &MEDIASUBTYPE_RGB565, CAP_NONE, "RGB565" },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
78 { 24, 24, &MEDIASUBTYPE_RGB24, CAP_NONE, "RGB24" },
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
79 { 32, 32, &MEDIASUBTYPE_RGB32, CAP_NONE, "RGB32" },
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
80
9963
alex
parents: 9503
diff changeset
81 {0,0,NULL,0},
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
82 };
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
83
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
84 DMO_VideoDecoder * DMO_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER * format, int flip, int maxauto)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
85 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
86 DMO_VideoDecoder *this;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
87 HRESULT result;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
88 ct* c;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
89
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
90 this = malloc(sizeof(DMO_VideoDecoder));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
91 memset( this, 0, sizeof(DMO_VideoDecoder));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
92
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
93 this->m_sVhdr2 = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
94 this->m_iLastQuality = -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
95 this->m_iMaxAuto = maxauto;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
96
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
97 #ifdef WIN32_LOADER
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
98 Setup_LDT_Keeper();
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
99 #endif
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
100
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
101 //memset(&m_obh, 0, sizeof(m_obh));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
102 //m_obh.biSize = sizeof(m_obh);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
103 /*try*/
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
104 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
105 unsigned int bihs;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
106
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
107 bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ?
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
108 sizeof(BITMAPINFOHEADER) : format->biSize;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
109
18878
3bf0d70b4c7f rm unnecesary casts from void* - part 2
reynaldo
parents: 15919
diff changeset
110 this->iv.m_bh = malloc(bihs);
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
111 memcpy(this->iv.m_bh, format, bihs);
22186
c6edb6c59a7a Precent overflow of this->m_sVhdr->bmiHeader buffer, may have been
rtogni
parents: 22001
diff changeset
112 this->iv.m_bh->biSize = bihs;
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
113
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
114 this->iv.m_State = STOP;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
115 //this->iv.m_pFrame = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
116 this->iv.m_Mode = DIRECT;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
117 this->iv.m_iDecpos = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
118 this->iv.m_iPlaypos = -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
119 this->iv.m_fQuality = 0.0f;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
120 this->iv.m_bCapable16b = true;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
121
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
122 bihs += sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER);
18878
3bf0d70b4c7f rm unnecesary casts from void* - part 2
reynaldo
parents: 15919
diff changeset
123 this->m_sVhdr = malloc(bihs);
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
124 memset(this->m_sVhdr, 0, bihs);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
125 memcpy(&this->m_sVhdr->bmiHeader, this->iv.m_bh, this->iv.m_bh->biSize);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
126 this->m_sVhdr->rcSource.left = this->m_sVhdr->rcSource.top = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
127 this->m_sVhdr->rcSource.right = this->m_sVhdr->bmiHeader.biWidth;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
128 this->m_sVhdr->rcSource.bottom = this->m_sVhdr->bmiHeader.biHeight;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
129 //this->m_sVhdr->rcSource.right = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
130 //this->m_sVhdr->rcSource.bottom = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
131 this->m_sVhdr->rcTarget = this->m_sVhdr->rcSource;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
132
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
133 this->m_sOurType.majortype = MEDIATYPE_Video;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
134 this->m_sOurType.subtype = MEDIATYPE_Video;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
135 this->m_sOurType.subtype.f1 = this->m_sVhdr->bmiHeader.biCompression;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
136 this->m_sOurType.formattype = FORMAT_VideoInfo;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
137 this->m_sOurType.bFixedSizeSamples = false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
138 this->m_sOurType.bTemporalCompression = true;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
139 this->m_sOurType.pUnk = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
140 this->m_sOurType.cbFormat = bihs;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
141 this->m_sOurType.pbFormat = (char*)this->m_sVhdr;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
142
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
143 this->m_sVhdr2 = (VIDEOINFOHEADER*)(malloc(sizeof(VIDEOINFOHEADER)+12));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
144 memcpy(this->m_sVhdr2, this->m_sVhdr, sizeof(VIDEOINFOHEADER));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
145 memset((char*)this->m_sVhdr2 + sizeof(VIDEOINFOHEADER), 0, 12);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
146 this->m_sVhdr2->bmiHeader.biCompression = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
147 this->m_sVhdr2->bmiHeader.biBitCount = 24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
148
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
149 // memset((char*)this->m_sVhdr2, 0, sizeof(VIDEOINFOHEADER)+12);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
150 this->m_sVhdr2->rcTarget = this->m_sVhdr->rcTarget;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
151 // this->m_sVhdr2->rcSource = this->m_sVhdr->rcSource;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
152
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
153 memset(&this->m_sDestType, 0, sizeof(this->m_sDestType));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
154 this->m_sDestType.majortype = MEDIATYPE_Video;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
155 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
156 this->m_sDestType.formattype = FORMAT_VideoInfo;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
157 this->m_sDestType.bFixedSizeSamples = true;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
158 this->m_sDestType.bTemporalCompression = false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
159 this->m_sDestType.lSampleSize = labs(this->m_sVhdr2->bmiHeader.biWidth*this->m_sVhdr2->bmiHeader.biHeight
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
160 * ((this->m_sVhdr2->bmiHeader.biBitCount + 7) / 8));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
161 this->m_sVhdr2->bmiHeader.biSizeImage = this->m_sDestType.lSampleSize;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
162 this->m_sDestType.pUnk = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
163 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
164 this->m_sDestType.pbFormat = (char*)this->m_sVhdr2;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
165
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
166 memset(&this->iv.m_obh, 0, sizeof(this->iv.m_obh));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
167 memcpy(&this->iv.m_obh, this->iv.m_bh, sizeof(this->iv.m_obh) < (unsigned) this->iv.m_bh->biSize
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
168 ? sizeof(this->iv.m_obh) : (unsigned) this->iv.m_bh->biSize);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
169 this->iv.m_obh.biBitCount=24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
170 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
171 this->iv.m_obh.biCompression = 0; //BI_RGB
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
172 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
173 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
174 * ((this->iv.m_obh.biBitCount + 7) / 8);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
175
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
176
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
177 this->m_pDMO_Filter = DMO_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
178
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
179 if (!this->m_pDMO_Filter)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
180 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
181 printf("Failed to create DMO filter\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
182 return 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
183 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
184
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
185 if (!flip)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
186 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
187 this->iv.m_obh.biHeight *= -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
188 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
189 // result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
190 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
191 if (result)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
192 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
193 printf("Decoder does not support upside-down RGB frames\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
194 this->iv.m_obh.biHeight *= -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
195 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
196 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
197 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
198
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
199 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh) );
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
200
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
201 switch (this->iv.m_bh->biCompression)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
202 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
203 #if 0
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
204 case fccDIV3:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
205 case fccDIV4:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
206 case fccDIV5:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
207 case fccDIV6:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
208 case fccMP42:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
209 case fccWMV2:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
210 //YV12 seems to be broken for DivX :-) codec
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
211 // case fccIV50:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
212 //produces incorrect picture
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
213 //m_Caps = (CAPS) (m_Caps & ~CAP_YV12);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
214 //m_Caps = CAP_UYVY;//CAP_YUY2; // | CAP_I420;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
215 //m_Caps = CAP_I420;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
216 this->m_Caps = (CAP_YUY2 | CAP_UYVY);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
217 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
218 #endif
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
219 default:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
220
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
221 this->m_Caps = CAP_NONE;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
222
15574
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
223 printf("Decoder supports the following formats: ");
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
224 for (c = check; c->bits; c++)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
225 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
226 this->m_sVhdr2->bmiHeader.biBitCount = c->bits;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
227 this->m_sVhdr2->bmiHeader.biCompression = c->fcc;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
228 this->m_sDestType.subtype = *c->subtype;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
229 //result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
230 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
231 if (!result)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
232 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
233 this->m_Caps = (this->m_Caps | c->cap);
15574
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
234 if (c->name)
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
235 printf("%s ", c->name);
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
236 else
0feaed9986d3 This currently sends control characters to the terminal instead of
rtognimp
parents: 10887
diff changeset
237 printf("%.4s ", (char*) &c->fcc);
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
238 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
239 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
240 printf("\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
241 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
242
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
243 if (this->m_Caps != CAP_NONE)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
244 printf("Decoder is capable of YUV output (flags 0x%x)\n", (int)this->m_Caps);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
245
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
246 this->m_sVhdr2->bmiHeader.biBitCount = 24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
247 this->m_sVhdr2->bmiHeader.biCompression = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
248 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
249
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
250 this->m_iMinBuffers = this->iv.VBUFSIZE;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
251 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
252 /*catch (FatalError& error)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
253 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
254 delete[] m_sVhdr;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
255 delete[] m_sVhdr2;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
256 delete m_pDMO_Filter;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
257 throw;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
258 }*/
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
259 return this;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
260 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
261
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
262 void DMO_VideoDecoder_Destroy(DMO_VideoDecoder *this)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
263 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
264 DMO_VideoDecoder_StopInternal(this);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
265 this->iv.m_State = STOP;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
266 free(this->m_sVhdr);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
267 free(this->m_sVhdr2);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
268 DMO_Filter_Destroy(this->m_pDMO_Filter);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
269 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
270
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
271 void DMO_VideoDecoder_StartInternal(DMO_VideoDecoder *this)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
272 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
273 #if 0
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
274 ALLOCATOR_PROPERTIES props, props1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
275 Debug printf("DMO_VideoDecoder_StartInternal\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
276 //cout << "DSSTART" << endl;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
277 this->m_pDMO_Filter->Start(this->m_pDMO_Filter);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
278
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
279 props.cBuffers = 1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
280 props.cbBuffer = this->m_sDestType.lSampleSize;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
281
9503
f47d484d8f28 cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents: 8451
diff changeset
282 props.cbAlign = 1;
f47d484d8f28 cbAlign=1 fix for proper Windows support (noticed by Sascha Sommer)
alex
parents: 8451
diff changeset
283 props.cbPrefix = 0;
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
284 this->m_pDMO_Filter->m_pAll->vt->SetProperties(this->m_pDMO_Filter->m_pAll, &props, &props1);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
285 this->m_pDMO_Filter->m_pAll->vt->Commit(this->m_pDMO_Filter->m_pAll);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
286 #endif
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
287 this->iv.m_State = START;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
288 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
289
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
290 void DMO_VideoDecoder_StopInternal(DMO_VideoDecoder *this)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
291 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
292 // this->m_pDMO_Filter->Stop(this->m_pDMO_Filter);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
293 //??? why was this here ??? m_pOurOutput->SetFramePointer(0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
294 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
295
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
296 int DMO_VideoDecoder_DecodeInternal(DMO_VideoDecoder *this, const void* src, int size, int is_keyframe, char* imdata)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
297 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
298 // IMediaSample* sample = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
299 int result;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
300 unsigned long status; // to be ignored by M$ specs
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
301 DMO_OUTPUT_DATA_BUFFER db;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
302 CMediaBuffer* bufferin;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
303 //+ uint8_t* imdata = dest ? dest->Data() : 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
304
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
305 Debug printf("DMO_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,imdata);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
306
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
307 // this->m_pDMO_Filter->m_pAll->vt->GetBuffer(this->m_pDMO_Filter->m_pAll, &sample, 0, 0, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
308 // if (!sample)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
309 // {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
310 // Debug printf("ERROR: null sample\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
311 // return -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
312 // }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
313
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
314 #ifdef WIN32_LOADER
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
315 Setup_FS_Segment();
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
316 #endif
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
317
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
318 bufferin = CMediaBufferCreate(size, (void*)src, size, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
319 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessInput(this->m_pDMO_Filter->m_pMedia, 0,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
320 (IMediaBuffer*)bufferin,
15919
b612f732e420 hardcode SYNC flag, so no problems could rise if first frame is skipped
iive
parents: 15574
diff changeset
321 DMO_INPUT_DATA_BUFFERF_SYNCPOINT,
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
322 0, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
323 ((IMediaBuffer*)bufferin)->vt->Release((IUnknown*)bufferin);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
324
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
325 if (result != S_OK)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
326 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
327 /* something for process */
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
328 if (result != S_FALSE)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
329 printf("ProcessInputError r:0x%x=%d (keyframe: %d)\n", result, result, is_keyframe);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
330 else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
331 printf("ProcessInputError FALSE ?? (keyframe: %d)\n", is_keyframe);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
332 return size;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
333 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
334
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
335 db.rtTimestamp = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
336 db.rtTimelength = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
337 db.dwStatus = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
338 db.pBuffer = (IMediaBuffer*) CMediaBufferCreate(this->m_sDestType.lSampleSize,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
339 imdata, 0, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
340 result = this->m_pDMO_Filter->m_pMedia->vt->ProcessOutput(this->m_pDMO_Filter->m_pMedia,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
341 (imdata) ? 0 : DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
342 1, &db, &status);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
343 //m_pDMO_Filter->m_pMedia->vt->Lock(m_pDMO_Filter->m_pMedia, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
344 if ((unsigned)result == DMO_E_NOTACCEPTING)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
345 printf("ProcessOutputError: Not accepting\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
346 else if (result)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
347 printf("ProcessOutputError: r:0x%x=%d %ld stat:%ld\n", result, result, status, db.dwStatus);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
348
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
349 ((IMediaBuffer*)db.pBuffer)->vt->Release((IUnknown*)db.pBuffer);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
350
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
351 //int r = m_pDMO_Filter->m_pMedia->vt->Flush(m_pDMO_Filter->m_pMedia);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
352 //printf("FLUSH %d\n", r);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
353
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
354 return 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
355 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
356
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
357 /*
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
358 * bits == 0 - leave unchanged
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
359 */
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
360 //int SetDestFmt(DMO_VideoDecoder * this, int bits = 24, fourcc_t csp = 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
361 int DMO_VideoDecoder_SetDestFmt(DMO_VideoDecoder *this, int bits, unsigned int csp)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
362 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
363 HRESULT result;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
364 int should_test=1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
365
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
366 Debug printf("DMO_VideoDecoder_SetDestFmt (%p, %d, %d)\n",this,bits,(int)csp);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
367
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
368 /* if (!CImage::Supported(csp, bits))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
369 return -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
370 */
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
371 // BitmapInfo temp = m_obh;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
372
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
373 if (!csp) // RGB
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
374 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
375 int ok = true;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
376
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
377 switch (bits)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
378 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
379 case 15:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
380 this->m_sDestType.subtype = MEDIASUBTYPE_RGB555;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
381 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
382 case 16:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
383 this->m_sDestType.subtype = MEDIASUBTYPE_RGB565;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
384 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
385 case 24:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
386 this->m_sDestType.subtype = MEDIASUBTYPE_RGB24;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
387 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
388 case 32:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
389 this->m_sDestType.subtype = MEDIASUBTYPE_RGB32;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
390 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
391 default:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
392 ok = false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
393 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
394 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
395
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
396 if (ok) {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
397 this->iv.m_obh.biBitCount=bits;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
398 if( bits == 15 || bits == 16 ) {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
399 this->iv.m_obh.biSize=sizeof(BITMAPINFOHEADER)+12;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
400 this->iv.m_obh.biCompression=3;//BI_BITFIELDS
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
401 this->iv.m_obh.biSizeImage=abs((int)(2*this->iv.m_obh.biWidth*this->iv.m_obh.biHeight));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
402 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
403
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
404 if( bits == 16 ) {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
405 this->iv.m_obh.colors[0]=0xF800;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
406 this->iv.m_obh.colors[1]=0x07E0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
407 this->iv.m_obh.colors[2]=0x001F;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
408 } else if ( bits == 15 ) {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
409 this->iv.m_obh.colors[0]=0x7C00;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
410 this->iv.m_obh.colors[1]=0x03E0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
411 this->iv.m_obh.colors[2]=0x001F;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
412 } else {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
413 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
414 this->iv.m_obh.biCompression = 0; //BI_RGB
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
415 //this->iv.m_obh.biHeight = labs(this->iv.m_obh.biHeight);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
416 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
417 * ((this->iv.m_obh.biBitCount + 7) / 8);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
418 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
419 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
420 //.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
421 } else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
422 { // YUV
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
423 int ok = true;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
424 switch (csp)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
425 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
426 case fccYUY2:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
427 this->m_sDestType.subtype = MEDIASUBTYPE_YUY2;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
428 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
429 case fccYV12:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
430 this->m_sDestType.subtype = MEDIASUBTYPE_YV12;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
431 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
432 case fccIYUV:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
433 this->m_sDestType.subtype = MEDIASUBTYPE_IYUV;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
434 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
435 case fccI420:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
436 this->m_sDestType.subtype = MEDIASUBTYPE_I420;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
437 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
438 case fccUYVY:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
439 this->m_sDestType.subtype = MEDIASUBTYPE_UYVY;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
440 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
441 case fccYVYU:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
442 this->m_sDestType.subtype = MEDIASUBTYPE_YVYU;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
443 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
444 case fccYVU9:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
445 this->m_sDestType.subtype = MEDIASUBTYPE_YVU9;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
446 default:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
447 ok = false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
448 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
449 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
450
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
451 if (ok) {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
452 if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
453 this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
454 this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
455 this->iv.m_obh.biCompression=csp;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
456 this->iv.m_obh.biBitCount=bits;
10887
858e2605726c fix for the no video/black screen with some dmo/wmv9 movies
pl
parents: 9978
diff changeset
457
858e2605726c fix for the no video/black screen with some dmo/wmv9 movies
pl
parents: 9978
diff changeset
458 this->iv.m_obh.biSizeImage = labs(this->iv.m_obh.biWidth * this->iv.m_obh.biHeight)
858e2605726c fix for the no video/black screen with some dmo/wmv9 movies
pl
parents: 9978
diff changeset
459 * ((this->iv.m_obh.biBitCount + 7) / 8);
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
460 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
461 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
462 this->m_sDestType.lSampleSize = this->iv.m_obh.biSizeImage;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
463 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_obh, sizeof(this->iv.m_obh));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
464 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
465 if (this->m_sVhdr2->bmiHeader.biCompression == 3)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
466 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
467 else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
468 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
469
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
470
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
471 switch(csp)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
472 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
473 case fccYUY2:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
474 if(!(this->m_Caps & CAP_YUY2))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
475 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
476 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
477 case fccYV12:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
478 if(!(this->m_Caps & CAP_YV12))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
479 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
480 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
481 case fccIYUV:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
482 if(!(this->m_Caps & CAP_IYUV))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
483 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
484 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
485 case fccI420:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
486 if(!(this->m_Caps & CAP_I420))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
487 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
488 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
489 case fccUYVY:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
490 if(!(this->m_Caps & CAP_UYVY))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
491 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
492 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
493 case fccYVYU:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
494 if(!(this->m_Caps & CAP_YVYU))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
495 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
496 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
497 case fccYVU9:
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
498 if(!(this->m_Caps & CAP_YVU9))
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
499 should_test=false;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
500 break;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
501 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
502
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
503 #ifdef WIN32_LOADER
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
504 Setup_FS_Segment();
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 9963
diff changeset
505 #endif
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
506
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
507 // if(should_test)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
508 // result = this->m_pDMO_Filter->m_pOutputPin->vt->QueryAccept(this->m_pDMO_Filter->m_pOutputPin, &this->m_sDestType);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
509 // else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
510 // result = -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
511
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
512 // test accept
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
513 if(!this->m_pDMO_Filter) return 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
514 result = this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, DMO_SET_TYPEF_TEST_ONLY);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
515
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
516 if (result != 0)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
517 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
518 if (csp)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
519 printf("Warning: unsupported color space\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
520 else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
521 printf("Warning: unsupported bit depth\n");
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
522
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
523 this->m_sDestType.lSampleSize = this->iv.m_decoder.biSizeImage;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
524 memcpy(&(this->m_sVhdr2->bmiHeader), &this->iv.m_decoder, sizeof(this->iv.m_decoder));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
525 this->m_sVhdr2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
526 if (this->m_sVhdr2->bmiHeader.biCompression == 3)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
527 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER) + 12;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
528 else
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
529 this->m_sDestType.cbFormat = sizeof(VIDEOINFOHEADER);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
530
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
531 return -1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
532 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
533
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
534 memcpy( &this->iv.m_decoder, &this->iv.m_obh, sizeof(this->iv.m_obh));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
535
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
536 // m_obh=temp;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
537 // if(csp)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
538 // m_obh.biBitCount=BitmapInfo::BitCount(csp);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
539 this->iv.m_bh->biBitCount = bits;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
540
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
541 //DMO_VideoDecoder_Restart(this);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
542
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
543 this->m_pDMO_Filter->m_pMedia->vt->SetOutputType(this->m_pDMO_Filter->m_pMedia, 0, &this->m_sDestType, 0);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
544
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
545 return 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
546 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
547
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
548
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
549 int DMO_VideoDecoder_SetDirection(DMO_VideoDecoder *this, int d)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
550 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
551 this->iv.m_obh.biHeight = (d) ? this->iv.m_bh->biHeight : -this->iv.m_bh->biHeight;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
552 this->m_sVhdr2->bmiHeader.biHeight = this->iv.m_obh.biHeight;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
553 return 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
554 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
555