/* * Copyright (c) 2014 The WebM 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.
*/
staticvoid FillPlane(uint8_t *const buf, constint width, constint height, constint stride) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) {
buf[x + (y * stride)] = (x + (width * y)) % kBufMax;
}
}
}
staticvoid FillPlaneExtreme(uint8_t *const buf, constint width, constint height, constint stride) {
ACMRandom rnd; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) {
buf[x + (y * stride)] = rnd.Rand8() % 2 ? 255 : 0;
}
}
}
staticvoid ExtendPlane(uint8_t *buf, int crop_width, int crop_height, int width, int height, int stride, int padding) { // Copy the outermost visible pixel to a distance of at least 'padding.' // The buffers are allocated such that there may be excess space outside the // padding. As long as the minimum amount of padding is achieved it is not // necessary to fill this space as well.
uint8_t *left = buf - padding;
uint8_t *right = buf + crop_width; constint right_extend = padding + (width - crop_width); constint bottom_extend = padding + (height - crop_height);
// Fill the border pixels from the nearest image pixel. for (int y = 0; y < crop_height; ++y) {
memset(left, left[padding], padding);
memset(right, right[-1], right_extend);
left += stride;
right += stride;
}
left = buf - padding;
uint8_t *top = left - (stride * padding); // The buffer does not always extend as far as the stride. // Equivalent to padding + width + padding. constint extend_width = padding + crop_width + right_extend;
// The first row was already extended to the left and right. Copy it up. for (int y = 0; y < padding; ++y) {
memcpy(top, left, extend_width);
top += stride;
}
uint8_t *bottom = left + (crop_height * stride); for (int y = 0; y < bottom_extend; ++y) {
memcpy(bottom, left + (crop_height - 1) * stride, extend_width);
bottom += stride;
}
}
void ReferenceCopyFrame() { // Copy img_ to ref_img_ and extend frame borders. This will be used for // verifying extend_fn_ as well as copy_frame_fn_.
EXPECT_EQ(ref_img_.frame_size, img_.frame_size); for (int y = 0; y < img_.y_crop_height; ++y) { for (int x = 0; x < img_.y_crop_width; ++x) {
ref_img_.y_buffer[x + y * ref_img_.y_stride] =
img_.y_buffer[x + y * img_.y_stride];
}
}
for (int y = 0; y < img_.uv_crop_height; ++y) { for (int x = 0; x < img_.uv_crop_width; ++x) {
ref_img_.u_buffer[x + y * ref_img_.uv_stride] =
img_.u_buffer[x + y * img_.uv_stride];
ref_img_.v_buffer[x + y * ref_img_.uv_stride] =
img_.v_buffer[x + y * img_.uv_stride];
}
}
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.