Set and use uv_crop_[width|height]
Ensure consistent border extension by rounding uv_crop_* at image creation time. Where it was rounded problems could arise with the right and bottom extensions. When padding = 32, y_width = 64, and y_crop_width = 63: (padding + width - crop_width + 1) / 2 32 + 64 - 63 + 1 should equal 32 *but* 32 + 1 + 1 equals 34 giving a right buffer of 17 instead of 16. By calculating uv_crop_* earlier we round up at the appropriate time and for the same values: (y_crop_width + 1) / 2 63 + 1 / 2 64 (padding / 2) + uv_width - uv_crop_width 16 + 16 - 16 16 Change-Id: If866cd1b63444771440edb1432280ac83875969b
This commit is contained in:
Родитель
0cf0b02c4c
Коммит
e956c00762
|
@ -81,6 +81,8 @@ int vp8_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
|
||||||
ybf->y_height = aligned_height;
|
ybf->y_height = aligned_height;
|
||||||
ybf->y_stride = y_stride;
|
ybf->y_stride = y_stride;
|
||||||
|
|
||||||
|
ybf->uv_crop_width = (width + 1) / 2;
|
||||||
|
ybf->uv_crop_height = (height + 1) / 2;
|
||||||
ybf->uv_width = uv_width;
|
ybf->uv_width = uv_width;
|
||||||
ybf->uv_height = uv_height;
|
ybf->uv_height = uv_height;
|
||||||
ybf->uv_stride = uv_stride;
|
ybf->uv_stride = uv_stride;
|
||||||
|
|
|
@ -56,6 +56,9 @@ static void extend_plane(uint8_t *const src, int src_stride,
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
|
void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
|
||||||
|
const int uv_border = ybf->border / 2;
|
||||||
|
|
||||||
|
assert(ybf->border % 2 == 0);
|
||||||
assert(ybf->y_height - ybf->y_crop_height < 16);
|
assert(ybf->y_height - ybf->y_crop_height < 16);
|
||||||
assert(ybf->y_width - ybf->y_crop_width < 16);
|
assert(ybf->y_width - ybf->y_crop_width < 16);
|
||||||
assert(ybf->y_height - ybf->y_crop_height >= 0);
|
assert(ybf->y_height - ybf->y_crop_height >= 0);
|
||||||
|
@ -68,16 +71,16 @@ void vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) {
|
||||||
ybf->border + ybf->y_width - ybf->y_crop_width);
|
ybf->border + ybf->y_width - ybf->y_crop_width);
|
||||||
|
|
||||||
extend_plane(ybf->u_buffer, ybf->uv_stride,
|
extend_plane(ybf->u_buffer, ybf->uv_stride,
|
||||||
(ybf->y_crop_width + 1) / 2, (ybf->y_crop_height + 1) / 2,
|
ybf->uv_crop_width, ybf->uv_crop_height,
|
||||||
ybf->border / 2, ybf->border / 2,
|
uv_border, uv_border,
|
||||||
(ybf->border + ybf->y_height - ybf->y_crop_height + 1) / 2,
|
uv_border + ybf->uv_height - ybf->uv_crop_height,
|
||||||
(ybf->border + ybf->y_width - ybf->y_crop_width + 1) / 2);
|
uv_border + ybf->uv_width - ybf->uv_crop_width);
|
||||||
|
|
||||||
extend_plane(ybf->v_buffer, ybf->uv_stride,
|
extend_plane(ybf->v_buffer, ybf->uv_stride,
|
||||||
(ybf->y_crop_width + 1) / 2, (ybf->y_crop_height + 1) / 2,
|
ybf->uv_crop_width, ybf->uv_crop_height,
|
||||||
ybf->border / 2, ybf->border / 2,
|
uv_border, uv_border,
|
||||||
(ybf->border + ybf->y_height - ybf->y_crop_height + 1) / 2,
|
uv_border + ybf->uv_height - ybf->uv_crop_height,
|
||||||
(ybf->border + ybf->y_width - ybf->y_crop_width + 1) / 2);
|
uv_border + ybf->uv_width - ybf->uv_crop_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_VP9
|
#if CONFIG_VP9
|
||||||
|
|
Загрузка…
Ссылка в новой задаче