@@ -815,11 +815,39 @@ struct heif_error svt_encode_image(void* encoder_raw, const struct heif_image* i
815
815
auto * input_picture_buffer = (EbSvtIOFormat*) input_buffer.p_buffer ;
816
816
817
817
int bytesPerPixel = bitdepth_y > 8 ? 2 : 1 ;
818
+ std::vector<uint8_t > dummy_color_plane;
818
819
if (input_class == heif_image_input_class_alpha) {
819
820
int stride;
820
821
input_picture_buffer->luma = (uint8_t *) heif_image_get_plane_readonly (image, heif_channel_Y, &stride);
821
822
input_picture_buffer->y_stride = stride / bytesPerPixel;
822
823
input_buffer.n_filled_len = stride * encoded_height;
824
+
825
+ uint32_t uvWidth = get_subsampled_size_h (encoded_width, heif_channel_Cb, heif_chroma_420, scaling_mode::round_up);
826
+ uint32_t uvHeight = get_subsampled_size_v (encoded_height, heif_channel_Cb, heif_chroma_420, scaling_mode::round_up);
827
+ dummy_color_plane.resize (uvWidth * uvHeight);
828
+
829
+ if (bitdepth_y <= 8 ) {
830
+ uint8_t val = 1 << (bitdepth_y - 1 );
831
+ memset (dummy_color_plane.data (), val, uvWidth * uvHeight * bytesPerPixel);
832
+ }
833
+ else {
834
+ assert (bitdepth_y > 8 && bitdepth_y <= 16 );
835
+ uint16_t val = 1 << (bitdepth_y - 1 );
836
+ uint8_t high = static_cast <uint8_t >((val >> 8 ) & 0xFF );
837
+ uint8_t low = static_cast <uint8_t >(val & 0xFF );
838
+
839
+ for (uint32_t i=0 ;i<uvWidth*uvHeight;i++) {
840
+ dummy_color_plane[2 *i ] = low;
841
+ dummy_color_plane[2 *i+1 ] = high;
842
+ }
843
+ }
844
+
845
+ input_buffer.n_filled_len += 2 * uvWidth * uvHeight;
846
+ input_picture_buffer->cb_stride = uvWidth;
847
+ input_picture_buffer->cr_stride = uvWidth;
848
+
849
+ input_picture_buffer->cb = dummy_color_plane.data ();
850
+ input_picture_buffer->cr = dummy_color_plane.data ();
823
851
}
824
852
else {
825
853
int stride;
@@ -853,7 +881,6 @@ struct heif_error svt_encode_image(void* encoder_raw, const struct heif_image* i
853
881
}
854
882
855
883
856
-
857
884
// --- flush encoder
858
885
859
886
EbErrorType ret = EB_ErrorNone;
0 commit comments