@@ -170,8 +170,24 @@ VkResult VkVideoEncoder::LoadNextFrame(VkSharedBaseObj<VkVideoEncodeFrameInfo>&
170
170
int yCbCrConvResult = 0 ;
171
171
if (m_encoderConfig->input .bpp == 8 ) {
172
172
173
- // Load current 8-bit frame from file and convert to NV12
174
- yCbCrConvResult = YCbCrConvUtilsCpu<uint8_t >::I420ToNV12 (
173
+ if (m_encoderConfig->encodeChromaSubsampling == VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR) {
174
+ // Load current 8-bit frame from file and convert to 2-plane YUV444
175
+ yCbCrConvResult = YCbCrConvUtilsCpu<uint8_t >::I444ToP444 (
176
+ pInputFrameData + m_encoderConfig->input .planeLayouts [0 ].offset , // src_y
177
+ (int )m_encoderConfig->input .planeLayouts [0 ].rowPitch , // src_stride_y
178
+ pInputFrameData + m_encoderConfig->input .planeLayouts [1 ].offset , // src_u
179
+ (int )m_encoderConfig->input .planeLayouts [1 ].rowPitch , // src_stride_u
180
+ pInputFrameData + m_encoderConfig->input .planeLayouts [2 ].offset , // src_v
181
+ (int )m_encoderConfig->input .planeLayouts [2 ].rowPitch , // src_stride_v
182
+ writeImagePtr + dstSubresourceLayout[0 ].offset , // dst_y
183
+ (int )dstSubresourceLayout[0 ].rowPitch , // dst_stride_y
184
+ writeImagePtr + dstSubresourceLayout[1 ].offset , // dst_uv
185
+ (int )dstSubresourceLayout[1 ].rowPitch , // dst_stride_uv
186
+ std::min (m_encoderConfig->encodeWidth , m_encoderConfig->input .width ), // width
187
+ std::min (m_encoderConfig->encodeHeight , m_encoderConfig->input .height )); // height
188
+ } else {
189
+ // Load current 8-bit frame from file and convert to NV12
190
+ yCbCrConvResult = YCbCrConvUtilsCpu<uint8_t >::I420ToNV12 (
175
191
pInputFrameData + m_encoderConfig->input .planeLayouts [0 ].offset , // src_y,
176
192
(int )m_encoderConfig->input .planeLayouts [0 ].rowPitch , // src_stride_y,
177
193
pInputFrameData + m_encoderConfig->input .planeLayouts [1 ].offset , // src_u,
@@ -184,6 +200,7 @@ VkResult VkVideoEncoder::LoadNextFrame(VkSharedBaseObj<VkVideoEncodeFrameInfo>&
184
200
(int )dstSubresourceLayout[1 ].rowPitch , // dst_stride_uv,
185
201
std::min (m_encoderConfig->encodeWidth , m_encoderConfig->input .width ), // width
186
202
std::min (m_encoderConfig->encodeHeight , m_encoderConfig->input .height )); // height
203
+ }
187
204
188
205
} else if (m_encoderConfig->input .bpp == 10 ) { // 10-bit - actually 16-bit only for now.
189
206
@@ -194,8 +211,25 @@ VkResult VkVideoEncoder::LoadNextFrame(VkSharedBaseObj<VkVideoEncodeFrameInfo>&
194
211
shiftBits = 16 - m_encoderConfig->input .bpp ;
195
212
}
196
213
197
- // Load current 10-bit frame from file and convert to P010/P016
198
- yCbCrConvResult = YCbCrConvUtilsCpu<uint16_t >::I420ToNV12 (
214
+ if (m_encoderConfig->encodeChromaSubsampling == VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR) {
215
+ // Load current 10-bit frame from file and convert to 2-plane YUV444
216
+ yCbCrConvResult = YCbCrConvUtilsCpu<uint16_t >::I444ToP444 (
217
+ (const uint16_t *)(pInputFrameData + m_encoderConfig->input .planeLayouts [0 ].offset ), // src_y
218
+ (int )m_encoderConfig->input .planeLayouts [0 ].rowPitch , // src_stride_y
219
+ (const uint16_t *)(pInputFrameData + m_encoderConfig->input .planeLayouts [1 ].offset ), // src_u
220
+ (int )m_encoderConfig->input .planeLayouts [1 ].rowPitch , // src_stride_u
221
+ (const uint16_t *)(pInputFrameData + m_encoderConfig->input .planeLayouts [2 ].offset ), // src_v
222
+ (int )m_encoderConfig->input .planeLayouts [2 ].rowPitch , // src_stride_v
223
+ (uint16_t *)(writeImagePtr + dstSubresourceLayout[0 ].offset ), // dst_y
224
+ (int )dstSubresourceLayout[0 ].rowPitch , // dst_stride_y
225
+ (uint16_t *)(writeImagePtr + dstSubresourceLayout[1 ].offset ), // dst_uv
226
+ (int )dstSubresourceLayout[1 ].rowPitch , // dst_stride_uv
227
+ std::min (m_encoderConfig->encodeWidth , m_encoderConfig->input .width ), // width
228
+ std::min (m_encoderConfig->encodeHeight , m_encoderConfig->input .height ), // height
229
+ shiftBits);
230
+ } else {
231
+ // Load current 10-bit frame from file and convert to P010/P016
232
+ yCbCrConvResult = YCbCrConvUtilsCpu<uint16_t >::I420ToNV12 (
199
233
(const uint16_t *)(pInputFrameData + m_encoderConfig->input .planeLayouts [0 ].offset ), // src_y,
200
234
(int )m_encoderConfig->input .planeLayouts [0 ].rowPitch , // src_stride_y,
201
235
(const uint16_t *)(pInputFrameData + m_encoderConfig->input .planeLayouts [1 ].offset ), // src_u,
@@ -209,6 +243,7 @@ VkResult VkVideoEncoder::LoadNextFrame(VkSharedBaseObj<VkVideoEncodeFrameInfo>&
209
243
std::min (m_encoderConfig->encodeWidth , m_encoderConfig->input .width ), // width
210
244
std::min (m_encoderConfig->encodeHeight , m_encoderConfig->input .height ), // height
211
245
shiftBits);
246
+ }
212
247
213
248
} else {
214
249
assert (!" Requested bit-depth is not supported!" );
0 commit comments