This repository was archived by the owner on May 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvddriverproc.cpp
More file actions
150 lines (130 loc) · 4.37 KB
/
vddriverproc.cpp
File metadata and controls
150 lines (130 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "vd2\plugin\vdplugin.h"
#include "x264vfw.h"
extern VDLogProc g_logProc;
extern "C" LRESULT WINAPI attribute_align_arg VDDriverProc(DWORD_PTR dwDriverId, HDRVR hDriver, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
CODEC *codec = (CODEC *)dwDriverId;
switch (uMsg){
case VDICM_COMPRESS_INPUT_FORMAT:
{
int i_csp_keep = codec->config.i_colorspace;
if(X264_BIT_DEPTH==8){
switch (i_csp_keep){
case CSP_KEEP_I420:
return nsVDXPixmap::kPixFormat_YUV420_Planar;
case CSP_KEEP_I422:
return nsVDXPixmap::kPixFormat_YUV422_Planar;
case CSP_KEEP_I444:
return nsVDXPixmap::kPixFormat_YUV444_Planar;
case CSP_KEEP_RGB:
return nsVDXPixmap::kPixFormat_XRGB8888;
case CSP_KEEP_GRAY:
return nsVDXPixmap::kPixFormat_Y8;
default:
return nsVDXPixmap::kPixFormat_Null;
}
} else {
int max_value = (1 << X264_BIT_DEPTH)-1;
FilterModPixmapInfo* info = (FilterModPixmapInfo*)lParam1;
switch (i_csp_keep){
case CSP_KEEP_I420:
info->ref_r = max_value;
return nsVDXPixmap::kPixFormat_YUV420_Planar16;
case CSP_KEEP_I422:
info->ref_r = max_value;
return nsVDXPixmap::kPixFormat_YUV422_Planar16;
case CSP_KEEP_I444:
info->ref_r = max_value;
return nsVDXPixmap::kPixFormat_YUV444_Planar16;
case CSP_KEEP_RGB:
info->ref_r = max_value;
info->ref_g = max_value;
info->ref_b = max_value;
return nsVDXPixmap::kPixFormat_XRGB64;
case CSP_KEEP_GRAY:
info->ref_r = max_value;
return nsVDXPixmap::kPixFormat_Y16;
default:
return nsVDXPixmap::kPixFormat_Null;
}
}
}
case VDICM_COMPRESS_INPUT_INFO:
{
VDXPixmapLayout* px = (VDXPixmapLayout*)lParam1;
if(X264_BIT_DEPTH==8){
switch(px->format){
case nsVDXPixmap::kPixFormat_YUV420_Planar:
case nsVDXPixmap::kPixFormat_YUV422_Planar:
case nsVDXPixmap::kPixFormat_YUV444_Planar:
case nsVDXPixmap::kPixFormat_XRGB8888:
case nsVDXPixmap::kPixFormat_Y8:
return 1;
}
} else {
switch(px->format){
case nsVDXPixmap::kPixFormat_YUV420_Planar16:
case nsVDXPixmap::kPixFormat_YUV422_Planar16:
case nsVDXPixmap::kPixFormat_YUV444_Planar16:
case nsVDXPixmap::kPixFormat_XRGB64:
case nsVDXPixmap::kPixFormat_Y16:
return 1;
}
}
return 0;
}
case VDICM_COMPRESS_QUERY:
return x264vfw_compress_query(codec, 0, (BITMAPINFO *)lParam2, (VDXPixmapLayout*)lParam1);
case VDICM_COMPRESS_GET_FORMAT:
return x264vfw_compress_get_format(codec, 0, (BITMAPINFO *)lParam2, (VDXPixmapLayout*)lParam1);
case VDICM_COMPRESS_GET_SIZE:
return x264vfw_compress_get_size(codec, 0, (BITMAPINFO *)lParam2);
case VDICM_COMPRESS_BEGIN:
return x264vfw_compress_begin(codec, 0, (BITMAPINFO *)lParam2, (VDXPixmapLayout*)lParam1);
case VDICM_STREAMCONTROL:
return x264vfw_stream_control(codec, (VDXStreamControl *)lParam1);
case VDICM_GETSTREAMINFO:
return x264vfw_get_stream_info(codec, (VDXStreamInfo *)lParam1);
case VDICM_COMPRESS:
{
VDXPictureCompress pc;
pc.px = (VDXPixmapLayout*)lParam2;
return x264vfw_compress(codec, (ICCOMPRESS *)lParam1, &pc);
}
case VDICM_COMPRESS2:
return x264vfw_compress(codec, (ICCOMPRESS *)lParam1, (VDXPictureCompress *)lParam2);
case VDICM_COMPRESS_TRUNCATE:
codec->i_frame_remain = 0;
return 0;
case VDICM_LOGPROC:
g_logProc = (VDLogProc)lParam1;
return 0;
case VDICM_COMPRESS_MATRIX_INFO:
{
int colorSpaceMode = lParam1;
int colorRangeMode = lParam2;
switch(colorSpaceMode){
case nsVDXPixmap::kColorSpaceMode_601:
codec->i_colormatrix = 5;
break;
case nsVDXPixmap::kColorSpaceMode_709:
codec->i_colormatrix = 1;
break;
default:
codec->i_colormatrix = -1;
}
switch(colorRangeMode){
case nsVDXPixmap::kColorRangeMode_Limited:
codec->b_fullrange = 0;
break;
case nsVDXPixmap::kColorRangeMode_Full:
codec->b_fullrange = 1;
break;
default:
codec->b_fullrange = -1;
}
return ICERR_OK;
}
}
return ICERR_UNSUPPORTED;
}