/* * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
protected: void WriteYuvFile(FILE* file, uint8_t y, uint8_t u, uint8_t v) {
RTC_DCHECK(file);
std::unique_ptr<uint8_t[]> plane_buffer(new uint8_t[y_size]);
memset(plane_buffer.get(), y, y_size);
fwrite(plane_buffer.get(), 1, y_size, file);
memset(plane_buffer.get(), u, uv_size);
fwrite(plane_buffer.get(), 1, uv_size, file);
memset(plane_buffer.get(), v, uv_size);
fwrite(plane_buffer.get(), 1, uv_size, file);
}
void WriteNV12File(FILE* file, uint8_t y, uint8_t u, uint8_t v) {
RTC_DCHECK(file);
uint8_t plane_buffer[y_size];
memset(&plane_buffer, y, y_size);
fwrite(&plane_buffer, 1, y_size, file); for (size_t i = 0; i < uv_size; ++i) {
plane_buffer[2 * i] = u;
plane_buffer[2 * i + 1] = v;
}
fwrite(&plane_buffer, 1, 2 * uv_size, file);
}
void CheckFrameAndMutate(const FrameGeneratorInterface::VideoFrameData& frame,
uint8_t y,
uint8_t u,
uint8_t v) { // Check that frame is valid, has the correct color and timestamp are clean.
rtc::scoped_refptr<I420BufferInterface> i420_buffer =
frame.buffer->ToI420(); const uint8_t* buffer;
buffer = i420_buffer->DataY(); for (int i = 0; i < y_size; ++i)
ASSERT_EQ(y, buffer[i]);
buffer = i420_buffer->DataU(); for (int i = 0; i < uv_size; ++i)
ASSERT_EQ(u, buffer[i]);
buffer = i420_buffer->DataV(); for (int i = 0; i < uv_size; ++i)
ASSERT_EQ(v, buffer[i]);
}
uint64_t Hash(const FrameGeneratorInterface::VideoFrameData& frame) { // Generate a 64-bit hash from the frame's buffer.
uint64_t hash = 19;
rtc::scoped_refptr<I420BufferInterface> i420_buffer =
frame.buffer->ToI420(); const uint8_t* buffer = i420_buffer->DataY(); for (int i = 0; i < y_size; ++i) {
hash = (37 * hash) + buffer[i];
}
buffer = i420_buffer->DataU(); for (int i = 0; i < uv_size; ++i) {
hash = (37 * hash) + buffer[i];
}
buffer = i420_buffer->DataV(); for (int i = 0; i < uv_size; ++i) {
hash = (37 * hash) + buffer[i];
} return hash;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.