@desklink/host 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/NOTICE +23 -0
  2. package/README.md +107 -55
  3. package/bin/desklink-host.mjs +2 -2
  4. package/dist/bridge.d.ts +1 -0
  5. package/dist/bridge.d.ts.map +1 -1
  6. package/dist/bridge.js +12 -4
  7. package/dist/bridge.js.map +1 -1
  8. package/dist/engineProcess.d.ts.map +1 -1
  9. package/dist/engineProcess.js +1 -0
  10. package/dist/engineProcess.js.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/keeper.d.ts +52 -0
  16. package/dist/keeper.d.ts.map +1 -0
  17. package/dist/keeper.js +101 -0
  18. package/dist/keeper.js.map +1 -0
  19. package/dist/protocol.d.ts +26 -0
  20. package/dist/protocol.d.ts.map +1 -1
  21. package/dist/protocol.js.map +1 -1
  22. package/dist/resolveEngine.d.ts +3 -3
  23. package/dist/resolveEngine.d.ts.map +1 -1
  24. package/dist/resolveEngine.js +24 -11
  25. package/dist/resolveEngine.js.map +1 -1
  26. package/docs/BOUNDARY.md +20 -8
  27. package/docs/PROTOCOL.md +347 -24
  28. package/engine/Cargo.lock +47 -1
  29. package/engine/Cargo.toml +13 -2
  30. package/engine/build.rs +28 -2
  31. package/engine/native/nvenc_shim.c +453 -0
  32. package/engine/native/vaapi_shim.c +727 -0
  33. package/engine/native/vpx_shim.c +54 -4
  34. package/engine/native/vt_shim.c +448 -0
  35. package/engine/src/capture.rs +75 -55
  36. package/engine/src/capture_mac.rs +24 -14
  37. package/engine/src/convert.rs +286 -61
  38. package/engine/src/encoder.rs +122 -13
  39. package/engine/src/h264.rs +188 -0
  40. package/engine/src/h264_nvenc.rs +308 -0
  41. package/engine/src/h264_openh264.rs +735 -0
  42. package/engine/src/h264_vaapi.rs +263 -0
  43. package/engine/src/h264_vt.rs +368 -0
  44. package/engine/src/keeper.rs +622 -0
  45. package/engine/src/mac.rs +9 -6
  46. package/engine/src/main.rs +64 -4
  47. package/engine/src/peer.rs +887 -42
  48. package/engine/src/protocol.rs +153 -4
  49. package/engine/src/session.rs +1547 -137
  50. package/engine/src/x11.rs +210 -9
  51. package/engine/src/x11_mac.rs +12 -0
  52. package/engine/vendor/libva/COPYING +19 -0
  53. package/engine/vendor/libva/va/va.h +5450 -0
  54. package/engine/vendor/libva/va/va_dec_av1.h +695 -0
  55. package/engine/vendor/libva/va/va_dec_hevc.h +616 -0
  56. package/engine/vendor/libva/va/va_dec_jpeg.h +157 -0
  57. package/engine/vendor/libva/va/va_dec_vp8.h +249 -0
  58. package/engine/vendor/libva/va/va_dec_vp9.h +312 -0
  59. package/engine/vendor/libva/va/va_dec_vvc.h +688 -0
  60. package/engine/vendor/libva/va/va_drm.h +61 -0
  61. package/engine/vendor/libva/va/va_enc_av1.h +1010 -0
  62. package/engine/vendor/libva/va/va_enc_h264.h +659 -0
  63. package/engine/vendor/libva/va/va_enc_hevc.h +958 -0
  64. package/engine/vendor/libva/va/va_enc_jpeg.h +162 -0
  65. package/engine/vendor/libva/va/va_enc_mpeg2.h +308 -0
  66. package/engine/vendor/libva/va/va_enc_vp8.h +350 -0
  67. package/engine/vendor/libva/va/va_enc_vp9.h +639 -0
  68. package/engine/vendor/libva/va/va_fei.h +170 -0
  69. package/engine/vendor/libva/va/va_fei_h264.h +505 -0
  70. package/engine/vendor/libva/va/va_fei_hevc.h +254 -0
  71. package/engine/vendor/libva/va/va_prot.h +525 -0
  72. package/engine/vendor/libva/va/va_version.h +87 -0
  73. package/engine/vendor/libva/va/va_vpp.h +1590 -0
  74. package/engine/vendor/nv-codec-headers/LICENSE +24 -0
  75. package/engine/vendor/nv-codec-headers/README +7 -0
  76. package/engine/vendor/nv-codec-headers/include/ffnvcodec/nvEncodeAPI.h +3825 -0
  77. package/examples/reference-client.html +1 -1
  78. package/package.json +3 -2
@@ -0,0 +1,170 @@
1
+ /*
2
+ * Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved.
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a
5
+ * copy of this software and associated documentation files (the
6
+ * "Software"), to deal in the Software without restriction, including
7
+ * without limitation the rights to use, copy, modify, merge, publish,
8
+ * distribute, sub license, and/or sell copies of the Software, and to
9
+ * permit persons to whom the Software is furnished to do so, subject to
10
+ * the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice (including the
13
+ * next paragraph) shall be included in all copies or substantial portions
14
+ * of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * \file va_fei.h
27
+ * \brief The FEI encoding common API
28
+ */
29
+
30
+ #ifndef VA_FEI_H
31
+ #define VA_FEI_H
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+ #include <stdint.h>
38
+
39
+ /**
40
+ * \defgroup api_fei FEI encoding common API
41
+ *
42
+ * @{
43
+ */
44
+
45
+ /**
46
+ * \brief FEI specific attribute definitions
47
+ */
48
+ /** @name Attribute values for VAConfigAttribFEIFunctionType
49
+ *
50
+ * This is only for VAEntrypointFEI
51
+ * The desired type should be passed to driver when creating the configuration.
52
+ * If VA_FEI_FUNCTION_ENC_PAK is set, VA_FEI_FUNCTION_ENC and VA_FEI_FUNCTION_PAK
53
+ * will be ignored if set also. Combination of VA_FEI_FUNCTION_ENC and VA_FEI_FUNCTION_PAK
54
+ * is not valid. If VA_FEI_FUNCTION_ENC is set, there will be no bitstream output.
55
+ * If VA_FEI_FUNCTION_PAK is set, two extra input buffers for PAK are needed:
56
+ * VAEncFEIMVBufferType and VAEncFEIMBCodeBufferType.
57
+ * VA_FEI_FUNCTION_ENC_PAK is recommended for best performance.
58
+ *
59
+ **/
60
+ /**@{*/
61
+ /** \brief ENC only is supported */
62
+ #define VA_FEI_FUNCTION_ENC 0x00000001
63
+ /** \brief PAK only is supported */
64
+ #define VA_FEI_FUNCTION_PAK 0x00000002
65
+ /** \brief ENC_PAK is supported */
66
+ #define VA_FEI_FUNCTION_ENC_PAK 0x00000004
67
+
68
+ /**@}*/
69
+
70
+ /** \brief Attribute value for VAConfigAttribStats */
71
+ typedef union _VAConfigAttribValStats {
72
+ struct {
73
+ /** \brief Max number of past reference frames that are supported. */
74
+ uint32_t max_num_past_references : 4;
75
+ /** \brief Max number of future reference frames that are supported. */
76
+ uint32_t max_num_future_references : 4;
77
+ /** \brief Number of supported output buffers for VAStatsStatisticsParameter->outputs */
78
+ uint32_t num_outputs : 3;
79
+ /** \brief Interlaced content is supported */
80
+ uint32_t interlaced : 1;
81
+ uint32_t reserved : 20;
82
+ } bits;
83
+ uint32_t value;
84
+ } VAConfigAttribValStats;
85
+
86
+ typedef struct _VAPictureStats {
87
+ VASurfaceID picture_id;
88
+ /*
89
+ * see flags below.
90
+ */
91
+ uint32_t flags;
92
+ } VAPictureStats;
93
+ /* flags in VAPictureStats could be one of the following */
94
+ #define VA_PICTURE_STATS_INVALID 0x00000001
95
+ #define VA_PICTURE_STATS_PROGRESSIVE 0x00000000
96
+ #define VA_PICTURE_STATS_TOP_FIELD 0x00000002
97
+ #define VA_PICTURE_STATS_BOTTOM_FIELD 0x00000004
98
+ /** \brief picutre surface content updated indicator.
99
+ * The picture surface content is updated, it means temporary buffer like downscaled pixel data in driver
100
+ * internal needs be forced freshing
101
+ **/
102
+ #define VA_PICTURE_STATS_CONTENT_UPDATED 0x00000010
103
+
104
+ /** \brief Motion Vector and Statistics frame level controls.
105
+ * common part VAStatsStatisticsParameterBufferType for a MB or CTB
106
+ **/
107
+ typedef struct _VAStatsStatisticsParameter {
108
+ /** \brief Source surface ID. */
109
+ VAPictureStats input;
110
+
111
+ /** \brief Past reference surface ID pointer. */
112
+ VAPictureStats *past_references;
113
+
114
+ /** \brief Past reference surface number */
115
+ uint32_t num_past_references;
116
+
117
+ /** \brief Statistics output for past reference surface.
118
+ * Only enabling statistics output for past reference picture when *past_ref_stat_buf is a valid
119
+ * VABufferID, it is needed in case app wants statistics data of both reference and current pictures
120
+ * in very special use cases for better performance.
121
+ * The output layout is defined by VAStatsStatisticsBufferType(for progressive and top field of
122
+ * interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case), only
123
+ * pixel_average_16x16/pixel_average_8x8 and variance_16x16/variance_8x8 data are valid.
124
+ **/
125
+ VABufferID *past_ref_stat_buf;
126
+
127
+ /** \brief Future reference surface ID pointer. */
128
+ VAPictureStats *future_references;
129
+
130
+ /** \brief Future reference surface number */
131
+ uint32_t num_future_references;
132
+
133
+ /** \brief Statistics output for future reference surface.
134
+ * Only enabling statistics output for future reference picture when *past_ref_stat_buf is a valid
135
+ * VABufferID, it is needed in case app wants statistics data of both reference and current pictures
136
+ * in very special use cases for better performance.
137
+ * The output layout is defined by VAStatsStatisticsBufferType(for progressive and top field of
138
+ * interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case), only
139
+ * pixel_average_16x16/pixel_average_8x8 and variance_16x16/variance_8x8 data are valid.
140
+ **/
141
+ VABufferID *future_ref_stat_buf;
142
+
143
+ /** \brief ID of the output buffer.
144
+ * The number of outputs is determined by below DisableMVOutput and DisableStatisticsOutput.
145
+ * The output layout is defined by VAStatsMVBufferType, VAStatsStatisticsBufferType(for progressive and
146
+ * top field of interlaced case) and VAStatsStatisticsBottomFieldBufferType(only for interlaced case).
147
+ **/
148
+ VABufferID *outputs;
149
+
150
+ /** \brief MV predictor. It is valid only when mv_predictor_ctrl is not 0.
151
+ * Each block has a pair of MVs, one for past and one for future reference
152
+ * as defined by VAMotionVector. The block is in raster scan order.
153
+ * Buffer size shall not be less than the number of blocks multiplied by sizeof(VAMotionVector).
154
+ **/
155
+ VABufferID mv_predictor;
156
+
157
+ /** \brief QP input buffer. It is valid only when mb_qp is set to 1.
158
+ * The data in this buffer correspond to the input source.
159
+ * One QP per MB or CTB block in raster scan order, each QP is a signed char (8-bit) value.
160
+ **/
161
+ VABufferID qp;
162
+ } VAStatsStatisticsParameter;
163
+
164
+ /**@}*/
165
+
166
+ #ifdef __cplusplus
167
+ }
168
+ #endif
169
+
170
+ #endif /* VA_FEI_H */
@@ -0,0 +1,505 @@
1
+ /*
2
+ * Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved.
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a
5
+ * copy of this software and associated documentation files (the
6
+ * "Software"), to deal in the Software without restriction, including
7
+ * without limitation the rights to use, copy, modify, merge, publish,
8
+ * distribute, sub license, and/or sell copies of the Software, and to
9
+ * permit persons to whom the Software is furnished to do so, subject to
10
+ * the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice (including the
13
+ * next paragraph) shall be included in all copies or substantial portions
14
+ * of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * \file va_fei_h264.h
27
+ * \brief The FEI encoding H264 special API
28
+ */
29
+
30
+ #ifndef VA_FEI_H264_H
31
+ #define VA_FEI_H264_H
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+ #include <stdint.h>
38
+ #include "va_fei.h"
39
+
40
+ /**
41
+ * \defgroup api_fei_h264 H.264 FEI encoding API
42
+ *
43
+ * @{
44
+ */
45
+
46
+ /** \brief FEI frame level control buffer for H.264 */
47
+ typedef struct _VAEncMiscParameterFEIFrameControlH264 {
48
+ uint32_t function; /* one of the VAConfigAttribFEIFunctionType values */
49
+ /** \brief MB (16x16) control input buffer. It is valid only when (mb_input | mb_size_ctrl)
50
+ * is set to 1. The data in this buffer correspond to the input source. 16x16 MB is in raster scan order,
51
+ * each MB control data structure is defined by VAEncFEIMBControlH264.
52
+ * Buffer size shall not be less than the number of 16x16 blocks multiplied by
53
+ * sizeof(VAEncFEIMBControlH264).
54
+ * Note: if mb_qp is set, VAEncQPBufferH264 is expected.
55
+ */
56
+ VABufferID mb_ctrl;
57
+ /** \brief distortion output of MB ENC or ENC_PAK.
58
+ * Each 16x16 block has one distortion data with VAEncFEIDistortionH264 layout
59
+ * Buffer size shall not be less than the number of 16x16 blocks multiplied by
60
+ * sizeof(VAEncFEIDistortionH264).
61
+ */
62
+ VABufferID distortion;
63
+ /** \brief MVs data output of MB ENC.
64
+ * Each 16x16 block has one MVs data with layout VAMotionVector
65
+ * Buffer size shall not be less than the number of 16x16 blocks multiplied by
66
+ * sizeof(VAMotionVector) * 16.
67
+ */
68
+ VABufferID mv_data;
69
+ /** \brief MBCode data output of MB ENC.
70
+ * Each 16x16 block has one MB Code data with layout VAEncFEIMBCodeH264
71
+ * Buffer size shall not be less than the number of 16x16 blocks multiplied by
72
+ * sizeof(VAEncFEIMBCodeH264).
73
+ */
74
+ VABufferID mb_code_data;
75
+ /** \brief QP input buffer with layout VAEncQPBufferH264. It is valid only when mb_qp is set to 1.
76
+ * The data in this buffer correspond to the input source.
77
+ * One QP per 16x16 block in raster scan order, each QP is a signed char (8-bit) value.
78
+ **/
79
+ VABufferID qp;
80
+ /** \brief MV predictor. It is valid only when mv_predictor_enable is set to 1.
81
+ * Each 16x16 block has one or more pair of motion vectors and the corresponding
82
+ * reference indexes as defined by VAEncFEIMVPredictorH264. 16x16 block is in raster scan order.
83
+ * Buffer size shall not be less than the number of 16x16 blocks multiplied by
84
+ * sizeof(VAEncFEIMVPredictorH264). */
85
+ VABufferID mv_predictor;
86
+
87
+ /** \brief number of MV predictors. It must not be greater than maximum supported MV predictor. */
88
+ uint32_t num_mv_predictors_l0 : 16;
89
+ uint32_t num_mv_predictors_l1 : 16;
90
+
91
+ /** \brief motion search method definition
92
+ * 0: default value, diamond search
93
+ * 1: full search
94
+ * 2: diamond search
95
+ **/
96
+ uint32_t search_path : 8;
97
+ /** \brief maximum number of Search Units, valid range is [1, 63]
98
+ * 0 is treated as 1. reference search locations are grouped in a predefined pattern,
99
+ * and all locations within the same group must be either all are chosen or all are skipped.
100
+ * These predefined groups are called search unit (SU).*/
101
+ uint32_t len_sp : 8;
102
+ uint32_t reserved0 : 16;
103
+ /** \brief defines the bit-mask for disabling sub-partition
104
+ * The lower 4 bits are for the major partitions (sub-macroblock) and the higher 3 bits for minor partitions (with sub-partition for 4x(8x8) sub-macroblocks.
105
+ * xxxxxx1 : 16x16 sub-macroblock disabled
106
+ * xxxxx1x : 2x(16x8) sub-macroblock within 16x16 disabled
107
+ * xxxx1xx : 2x(8x16) sub-macroblock within 16x16 disabled
108
+ * xxx1xxx : 1x(8x8) sub-partition for 4x(8x8) within 16x16 disabled
109
+ * xx1xxxx : 2x(8x4) sub-partition for 4x(8x8) within 16x16 disabled
110
+ * x1xxxxx : 2x(4x8) sub-partition for 4x(8x8) within 16x16 disabled
111
+ * 1xxxxxx : 4x(4x4) sub-partition for 4x(8x8) within 16x16 disabled
112
+ * 1111111 : Invalid
113
+ * 0000000 : default value */
114
+ uint32_t sub_mb_part_mask : 7;
115
+ /** specifies which Luma Intra partition is enabled/disabled for intra mode decision.
116
+ * xxxx1: luma_intra_16x16 disabled
117
+ * xxx1x: luma_intra_8x8 disabled
118
+ * xx1xx: luma_intra_4x4 disabled
119
+ * xx111: intra prediction is disabled */
120
+ uint32_t intra_part_mask : 5;
121
+ /** when set to 1, neighbor MV will be used as predictor; when set to 0, no neighbor MV will be used as predictor.*/
122
+ uint32_t multi_pred_l0 : 1;
123
+ /** when set to 1, neighbor MV will be used as predictor; when set to 0, no neighbor MV will be used as predictor.*/
124
+ uint32_t multi_pred_l1 : 1;
125
+ /**defines the half/quarter pel modes. The mode is inclusive, ie., higher precision mode samples lower precision locations.
126
+ * 00b: integer mode searching
127
+ * 01b: half-pel mode searching
128
+ * 10b: reserved
129
+ * 11b: quarter-pel mode searching */
130
+ uint32_t sub_pel_mode : 2;
131
+ /** specifies distortion measure adjustments used for the inter motion search SAD comparison.
132
+ * 00b: none
133
+ * 10b: Haar transform adjusted*/
134
+ uint32_t inter_sad : 2;
135
+ /** specifies distortion measure adjustments used for the intra motion search SAD comparison.
136
+ * 00b: none
137
+ * 10b: Haar transform adjusted*/
138
+ uint32_t intra_sad : 2;
139
+ /** specifies if the output distortion is the raw distortion or cost adjusted distortion.
140
+ * 0: Raw Distortion without Cost
141
+ * 1: Distortion with added Cost */
142
+ uint32_t distortion_type : 1;
143
+ /** when set to 1, enables the additional calls on Fraction & Bidirectional Refinement*/
144
+ uint32_t repartition_check_enable : 1;
145
+ /** defines whether adaptive searching is enabled for IME(Integer Motion Estimation).
146
+ * 0: disable
147
+ * 1: enable */
148
+ uint32_t adaptive_search : 1;
149
+ /** enables using the motion vector as an extra predictor provided by the host. If it is set,
150
+ * host needs to provide a buffer with motion vectors and the associated reference index for
151
+ * each 16x16 block as defined . The host can call processing function to get motion vectors and use as predictor.
152
+ * 0: MV predictor disabled
153
+ * 1: MV predictor enabled */
154
+ uint32_t mv_predictor_enable : 1;
155
+ /** enables using the QP buffer to set the QP for each block*/
156
+ uint32_t mb_qp : 1;
157
+ /** enable mb_ctrl buffer to handle MB*/
158
+ uint32_t mb_input : 1;
159
+ /** when this flag is set, mb_ctrl must be set too and a buffer with per MB input
160
+ * needs to be provided and MaxSizeInWord and */
161
+ uint32_t mb_size_ctrl : 1;
162
+ /** when this flag is set, extra distortion between the current MB and co-located MB is provided.
163
+ * Extra distortion output has performance impact, set it only when it is needed.*/
164
+ uint32_t colocated_mb_distortion : 1;
165
+ uint32_t reserved1 : 4;
166
+
167
+ /** \brief motion search window(ref_width * ref_height) */
168
+ uint32_t ref_width : 8;
169
+ uint32_t ref_height : 8;
170
+ /** \brief predefined motion search windows. If selected, len_sp, window(ref_width * ref_eight)
171
+ * and search_path setting are ignored.
172
+ * 0: not use predefined search window
173
+ * 1: Tiny, len_sp=4, 24x24 window and diamond search
174
+ * 2: Small, len_sp=9, 28x28 window and diamond search
175
+ * 3: Diamond, len_sp=16, 48x40 window and diamond search
176
+ * 4: Large Diamond, len_sp=32, 48x40 window and diamond search
177
+ * 5: Exhaustive, len_sp=48, 48x40 window and full search
178
+ * 6: Extend Diamond, len_sp=16, 64x40 window and diamond search
179
+ * 7: Extend Large Diamond, len_sp=32, 64x40 window and diamond search
180
+ * 8: Extend Exhaustive, len_sp=48, 64x40 window and full search
181
+ **/
182
+ uint32_t search_window : 4;
183
+ uint32_t reserved2 : 12;
184
+
185
+ /** \brief max frame size control with multi passes QP setting */
186
+ uint32_t max_frame_size;
187
+ /** \brief number of passes, every pass has different QP */
188
+ uint32_t num_passes;
189
+ /** \brief delta QP list for every pass */
190
+ uint8_t *delta_qp;
191
+ uint32_t reserved3[VA_PADDING_LOW];
192
+ } VAEncMiscParameterFEIFrameControlH264;
193
+
194
+ /** \brief FEI MB level control data structure */
195
+ typedef struct _VAEncFEIMBControlH264 {
196
+ /** \brief when set, correposndent MB is coded as intra */
197
+ uint32_t force_to_intra : 1;
198
+ /** \brief when set, correposndent MB is coded as skip */
199
+ uint32_t force_to_skip : 1;
200
+ /** \brief specifies whether this macroblock should be coded as a non-skipped macroblock. */
201
+ uint32_t force_to_nonskip : 1;
202
+ uint32_t enable_direct_bias_adjustment : 1;
203
+ uint32_t enable_motion_bias_adjustment : 1;
204
+ uint32_t ext_mv_cost_scaling_factor : 3;
205
+ uint32_t reserved0 : 24;
206
+
207
+ uint32_t reserved1;
208
+
209
+ uint32_t reserved2;
210
+
211
+ uint32_t reserved3 : 16;
212
+ /** \brief when mb_size_ctrl is set, size here is used to budget accumulatively. Set to 0xFF if don't care. */
213
+ uint32_t target_size_in_word : 8;
214
+ /** \brief specifies the max size of each MB */
215
+ uint32_t max_size_in_word : 8;
216
+ } VAEncFEIMBControlH264;
217
+
218
+
219
+ /** \brief Application can use this definition as reference to allocate the buffer
220
+ * based on MaxNumPredictor returned from attribute VAConfigAttribFEIMVPredictors query.
221
+ **/
222
+ typedef struct _VAEncFEIMVPredictorH264 {
223
+ /** \brief Reference index corresponding to the entry of RefPicList0 & RefPicList1 in VAEncSliceParameterBufferH264.
224
+ * Note that RefPicList0 & RefPicList1 needs to be the same for all slices.
225
+ * ref_idx_l0_x : index to RefPicList0; ref_idx_l1_x : index to RefPicList1; x : 0 - MaxNumPredictor.
226
+ **/
227
+ struct {
228
+ uint8_t ref_idx_l0 : 4;
229
+ uint8_t ref_idx_l1 : 4;
230
+ } ref_idx[4]; /* index is predictor number */
231
+ uint32_t reserved;
232
+ /** \brief MV. MaxNumPredictor must be the returned value from attribute VAConfigAttribFEIMVPredictors query.
233
+ * Even application doesn't use the maximum predictors, the VAFEIMVPredictorH264 structure size
234
+ * has to be defined as maximum so each MB can be at a fixed location.
235
+ * Note that 0x8000 must be used for correspondent intra block.
236
+ **/
237
+ VAMotionVector mv[4]; /* MaxNumPredictor is 4 */
238
+ } VAEncFEIMVPredictorH264;
239
+
240
+ /** \brief FEI output */
241
+ /**
242
+ * Motion vector output is per 4x4 block. For each 4x4 block there is a pair of MVs
243
+ * for RefPicList0 and RefPicList1 and each MV is 4 bytes including horizontal and vertical directions.
244
+ * Depending on Subblock partition, for the shape that is not 4x4, the MV is replicated
245
+ * so each 4x4 block has a pair of MVs. The 16x16 block has 32 MVs (128 bytes).
246
+ * 0x8000 is used for correspondent intra block. The 16x16 block is in raster scan order,
247
+ * within the 16x16 block, each 4x4 block MV is ordered as below in memory.
248
+ * The buffer size shall be greater than or equal to the number of 16x16 blocks multiplied by 128 bytes.
249
+ * Note that, when separate ENC and PAK is enabled, the exact layout of this buffer is needed for PAK input.
250
+ * App can reuse this buffer, or copy to a different buffer as PAK input.
251
+ * Layout is defined as Generic motion vector data structure VAMotionVector
252
+ * 16x16 Block
253
+ * -----------------------------------------
254
+ * | 1 | 2 | 5 | 6 |
255
+ * -----------------------------------------
256
+ * | 3 | 4 | 7 | 8 |
257
+ * -----------------------------------------
258
+ * | 9 | 10 | 13 | 14 |
259
+ * -----------------------------------------
260
+ * | 11 | 12 | 15 | 16 |
261
+ * -----------------------------------------
262
+ **/
263
+
264
+ /** \brief VAEncFEIMBCodeH264 defines the data structure for VAEncFEIMBCodeBufferType per 16x16 MB block.
265
+ * it is output buffer of ENC and ENC_PAK modes, it's also input buffer of PAK mode.
266
+ * The 16x16 block is in raster scan order. Buffer size shall not be less than the number of 16x16 blocks
267
+ * multiplied by sizeof(VAEncFEIMBCodeH264). Note that, when separate ENC and PAK is enabled,
268
+ * the exact layout of this buffer is needed for PAK input. App can reuse this buffer,
269
+ * or copy to a different buffer as PAK input, reserved elements must not be modified when used as PAK input.
270
+ **/
271
+ typedef struct _VAEncFEIMBCodeH264 {
272
+ //DWORD 0~2
273
+ uint32_t reserved0[3];
274
+
275
+ //DWORD 3
276
+ uint32_t inter_mb_mode : 2;
277
+ uint32_t mb_skip_flag : 1;
278
+ uint32_t reserved1 : 1;
279
+ uint32_t intra_mb_mode : 2;
280
+ uint32_t reserved2 : 1;
281
+ uint32_t field_mb_polarity_flag : 1;
282
+ uint32_t mb_type : 5;
283
+ uint32_t intra_mb_flag : 1;
284
+ uint32_t field_mb_flag : 1;
285
+ uint32_t transform8x8_flag : 1;
286
+ uint32_t reserved3 : 1;
287
+ uint32_t dc_block_coded_cr_flag : 1;
288
+ uint32_t dc_block_coded_cb_flag : 1;
289
+ uint32_t dc_block_coded_y_flag : 1;
290
+ uint32_t reserved4 : 12;
291
+
292
+ //DWORD 4
293
+ uint32_t horz_origin : 8;
294
+ uint32_t vert_origin : 8;
295
+ uint32_t cbp_y : 16;
296
+
297
+ //DWORD 5
298
+ uint32_t cbp_cb : 16;
299
+ uint32_t cbp_cr : 16;
300
+
301
+ //DWORD 6
302
+ uint32_t qp_prime_y : 8;
303
+ uint32_t reserved5 : 17;
304
+ uint32_t mb_skip_conv_disable : 1;
305
+ uint32_t is_last_mb : 1;
306
+ uint32_t enable_coefficient_clamp : 1;
307
+ uint32_t direct8x8_pattern : 4;
308
+
309
+ //DWORD 7 8 and 9
310
+ union {
311
+ /* Intra MBs */
312
+ struct {
313
+ uint32_t luma_intra_pred_modes0 : 16;
314
+ uint32_t luma_intra_pred_modes1 : 16;
315
+
316
+ uint32_t luma_intra_pred_modes2 : 16;
317
+ uint32_t luma_intra_pred_modes3 : 16;
318
+
319
+ uint32_t chroma_intra_pred_mode : 2;
320
+ uint32_t intra_pred_avail_flag : 5;
321
+ uint32_t intra_pred_avail_flagF : 1;
322
+ uint32_t reserved6 : 24;
323
+ } intra_mb;
324
+
325
+ /* Inter MBs */
326
+ struct {
327
+ uint32_t sub_mb_shapes : 8;
328
+ uint32_t sub_mb_pred_modes : 8;
329
+ uint32_t reserved7 : 16;
330
+
331
+ uint32_t ref_idx_l0_0 : 8;
332
+ uint32_t ref_idx_l0_1 : 8;
333
+ uint32_t ref_idx_l0_2 : 8;
334
+ uint32_t ref_idx_l0_3 : 8;
335
+
336
+ uint32_t ref_idx_l1_0 : 8;
337
+ uint32_t ref_idx_l1_1 : 8;
338
+ uint32_t ref_idx_l1_2 : 8;
339
+ uint32_t ref_idx_l1_3 : 8;
340
+ } inter_mb;
341
+ } mb_mode;
342
+
343
+ //DWORD 10
344
+ uint32_t reserved8 : 16;
345
+ uint32_t target_size_in_word : 8;
346
+ uint32_t max_size_in_word : 8;
347
+
348
+ //DWORD 11~14
349
+ uint32_t reserved9[4];
350
+
351
+ //DWORD 15
352
+ uint32_t reserved10;
353
+ } VAEncFEIMBCodeH264; // 64 bytes
354
+
355
+ /** \brief VAEncFEIDistortionH264 defines the data structure for VAEncFEIDistortionBufferType per 16x16 MB block.
356
+ * It is output buffer of ENC and ENC_PAK modes, The 16x16 block is in raster scan order.
357
+ * Buffer size shall not be less than the number of 16x16 blocks multiple by sizeof(VAEncFEIDistortionH264).
358
+ **/
359
+ typedef struct _VAEncFEIDistortionH264 {
360
+ /** \brief Inter-prediction-distortion associated with motion vector i (co-located with subblock_4x4_i).
361
+ * Its meaning is determined by sub-shape. It must be zero if the corresponding sub-shape is not chosen.
362
+ **/
363
+ uint16_t inter_distortion[16];
364
+ uint32_t best_inter_distortion : 16;
365
+ uint32_t best_intra_distortion : 16;
366
+ uint32_t colocated_mb_distortion : 16;
367
+ uint32_t reserved0 : 16;
368
+ uint32_t reserved1[2];
369
+ } VAEncFEIDistortionH264; // 48 bytes
370
+
371
+ /** \brief Motion Vector and Statistics frame level controls.
372
+ * VAStatsStatisticsParameterBufferType for H264 16x16 block
373
+ **/
374
+ typedef struct _VAStatsStatisticsParameterH264 {
375
+ VAStatsStatisticsParameter stats_params;
376
+
377
+ uint32_t frame_qp : 8;
378
+ /** \brief length of search path */
379
+ uint32_t len_sp : 8;
380
+ /** \brief motion search method definition
381
+ * 0: default value, diamond search
382
+ * 1: full search
383
+ * 2: diamond search
384
+ **/
385
+ uint32_t search_path : 8;
386
+ uint32_t reserved0 : 8;
387
+
388
+ uint32_t sub_mb_part_mask : 7;
389
+ /** \brief sub pixel mode definition
390
+ * 00b: integer mode searching
391
+ * 01b: half-pel mode searching
392
+ * 10b: reserved
393
+ * 11b: quarter-pel mode searching
394
+ **/
395
+ uint32_t sub_pel_mode : 2;
396
+ /** \brief distortion measure adjustment for inter search SAD comparison
397
+ * 00b: none
398
+ * 01b: reserved
399
+ * 10b: Haar transform adjusted
400
+ * 11b: reserved
401
+ **/
402
+ uint32_t inter_sad : 2;
403
+ /** \brief distortion measure adjustment for intra search SAD comparison
404
+ * 00b: none
405
+ * 01b: reserved
406
+ * 10b: Haar transform adjusted
407
+ * 11b: reserved
408
+ **/
409
+ uint32_t intra_sad : 2;
410
+ uint32_t adaptive_search : 1;
411
+ /** \brief indicate if future or/and past MV in mv_predictor buffer is valid.
412
+ * 0: MV predictor disabled
413
+ * 1: MV predictor enabled for past reference
414
+ * 2: MV predictor enabled for future reference
415
+ * 3: MV predictor enabled for both past and future references
416
+ **/
417
+ uint32_t mv_predictor_ctrl : 3;
418
+ uint32_t mb_qp : 1;
419
+ /** \brief forward transform enable
420
+ * 0: disable
421
+ * 1: enable, needs frame_qp or mb_qp input for transform
422
+ **/
423
+ uint32_t ft_enable : 1;
424
+ /** \brief luma intra mode partition mask
425
+ * xxxx1: luma_intra_16x16 disabled
426
+ * xxx1x: luma_intra_8x8 disabled
427
+ * xx1xx: luma_intra_4x4 disabled
428
+ * xx111: intra prediction is disabled
429
+ **/
430
+ uint32_t intra_part_mask : 5;
431
+ uint32_t reserved1 : 8;
432
+
433
+ /** \brief motion search window(ref_width * ref_height) */
434
+ uint32_t ref_width : 8;
435
+ uint32_t ref_height : 8;
436
+ /** \brief predefined motion search windows. If selected, len_sp, window(ref_width * ref_eight)
437
+ * and search_path setting are ignored.
438
+ * 0: not use predefined search window
439
+ * 1: Tiny, len_sp=4, 24x24 window and diamond search
440
+ * 2: Small, len_sp=9, 28x28 window and diamond search
441
+ * 3: Diamond, len_sp=16, 48x40 window and diamond search
442
+ * 4: Large Diamond, len_sp=32, 48x40 window and diamond search
443
+ * 5: Exhaustive, len_sp=48, 48x40 window and full search
444
+ * 6: Extend Diamond, len_sp=16, 64x40 window and diamond search
445
+ * 7: Extend Large Diamond, len_sp=32, 64x40 window and diamond search
446
+ * 8: Extend Exhaustive, len_sp=48, 64x40 window and full search
447
+ **/
448
+ uint32_t search_window : 4;
449
+ uint32_t reserved2 : 12;
450
+
451
+ /** \brief MVOutput. When set to 1, MV output is NOT provided */
452
+ uint32_t disable_mv_output : 1;
453
+ /** \brief StatisticsOutput. When set to 1, Statistics output is NOT provided. */
454
+ uint32_t disable_statistics_output : 1;
455
+ /** \brief block 8x8 data enabling in statistics output */
456
+ uint32_t enable_8x8_statistics : 1;
457
+ uint32_t reserved3 : 29;
458
+ uint32_t reserved4[2];
459
+ } VAStatsStatisticsParameterH264;
460
+
461
+ /** \brief VAStatsStatisticsH264. H264 Statistics buffer layout for VAStatsStatisticsBufferType
462
+ * and VAStatsStatisticsBottomFieldBufferType(for interlaced only).
463
+ * Statistics output is per 16x16 block. Data structure per 16x16 block is defined below.
464
+ * The 16x16 block is in raster scan order. The buffer size shall be greater than or equal to
465
+ * the number of 16x16 blocks multiplied by sizeof(VAStatsStatisticsH264).
466
+ **/
467
+ typedef struct _VAStatsStatisticsH264 {
468
+ /** \brief past reference */
469
+ uint32_t best_inter_distortion0 : 16;
470
+ uint32_t inter_mode0 : 16;
471
+
472
+ /** \brief future reference */
473
+ uint32_t best_inter_distortion1 : 16;
474
+ uint32_t inter_mode1 : 16;
475
+
476
+ uint32_t best_intra_distortion : 16;
477
+ uint32_t intra_mode : 16;
478
+
479
+ uint32_t num_non_zero_coef : 16;
480
+ uint32_t reserved0 : 16;
481
+
482
+ uint32_t sum_coef;
483
+
484
+ /** \brief DWORD 5 flat info **/
485
+ uint32_t mb_is_flat : 1;
486
+ uint32_t reserved1 : 31;
487
+
488
+ /** \brief DWORD 6 variance for block16x16**/
489
+ uint32_t variance_16x16;
490
+ /** \brief DWORD 7 ~ 10, variance for block8x8 **/
491
+ uint32_t variance_8x8[4];
492
+
493
+ /** \brief DWORD 11 pixel_average for block16x16 **/
494
+ uint32_t pixel_average_16x16;
495
+ /** \brief DWORD 12 ~ 15, pixel_average for block8x8 **/
496
+ uint32_t pixel_average_8x8[4];
497
+ } VAStatsStatisticsH264; // 64 bytes
498
+
499
+ /**@}*/
500
+
501
+ #ifdef __cplusplus
502
+ }
503
+ #endif
504
+
505
+ #endif /* VA_FEI_H264_H */