Project import generated by Copybara.

GitOrigin-RevId: b695dda274aa3ac3c7d054e150bd9eb5c1285b19
This commit is contained in:
MediaPipe Team
2020-01-17 15:49:22 -08:00
committed by chris
parent 66b377c825
commit dd02df1dbe
39 changed files with 692 additions and 203 deletions
+3 -2
View File
@@ -371,11 +371,12 @@ void ImageFrame::CopyPixelData(ImageFormat::Format format, int width,
void ImageFrame::CopyToBuffer(uint8* buffer, int buffer_size) const {
CHECK(buffer);
CHECK_EQ(1, ByteDepth());
int data_size = width_ * height_ * NumberOfChannels() * ByteDepth();
const int data_size = width_ * height_ * NumberOfChannels();
CHECK_LE(data_size, buffer_size);
if (IsContiguous()) {
// The data is stored contiguously, we can just copy.
std::copy_n(pixel_data_.get(), data_size, buffer);
const uint8* src = reinterpret_cast<const uint8*>(pixel_data_.get());
std::copy_n(src, data_size, buffer);
} else {
InternalCopyToBuffer(0 /* contiguous storage */,
reinterpret_cast<char*>(buffer));