// Aligning pointer to 64 bytes for improved performance, e.g. use SIMD. staticconst int kBufferAlignment = 64; staticconst int kBytesPerPixel = 2;
namespace webrtc {
namespace {
int I210DataSize(int width,
int height,
int stride_y,
int stride_u,
int stride_v) {
CheckValidDimensions(width, height, stride_y, stride_u, stride_v);
int64_t h = height, y = stride_y, u = stride_u, v = stride_v; return checked_cast<int>(kBytesPerPixel * (y * h + u * h + v * h));
}
} // namespace
I210Buffer::I210Buffer(int width,
int height,
int stride_y,
int stride_u,
int stride_v)
: width_(width),
height_(height),
stride_y_(stride_y),
stride_u_(stride_u),
stride_v_(stride_v),
data_(static_cast<uint16_t*>(AlignedMalloc(
I210DataSize(width, height, stride_y, stride_u, stride_v),
kBufferAlignment))) {
RTC_DCHECK_GE(stride_u, (width + 1) / 2);
RTC_DCHECK_GE(stride_v, (width + 1) / 2);
}
void I210Buffer::CropAndScaleFrom(const I210BufferInterface& src,
int offset_x,
int offset_y,
int crop_width,
int crop_height) {
RTC_CHECK_LE(crop_width, src.width());
RTC_CHECK_LE(crop_height, src.height());
RTC_CHECK_LE(crop_width + offset_x, src.width());
RTC_CHECK_LE(crop_height + offset_y, src.height());
RTC_CHECK_GE(offset_x, 0);
RTC_CHECK_GE(offset_y, 0);
RTC_CHECK_GE(crop_width, 0);
RTC_CHECK_GE(crop_height, 0);
// Make sure offset is even so that u/v plane becomes aligned. const int uv_offset_x = offset_x / 2; const int uv_offset_y = offset_y;
offset_x = uv_offset_x * 2;
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.