mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
Add support for odd width and height in I410ToI420
Bug: libyuv:950 Change-Id: Ic9a094463af875aefd927023f730b5f35f8551de Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4154630 Commit-Queue: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
parent
0809713775
commit
b2528b0be9
@ -275,6 +275,11 @@ void ScaleRowDown2_16To8_C(const uint16_t* src_ptr,
|
|||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
int dst_width,
|
int dst_width,
|
||||||
int scale);
|
int scale);
|
||||||
|
void ScaleRowDown2_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale);
|
||||||
void ScaleRowDown2Linear_C(const uint8_t* src_ptr,
|
void ScaleRowDown2Linear_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
@ -288,6 +293,11 @@ void ScaleRowDown2Linear_16To8_C(const uint16_t* src_ptr,
|
|||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
int dst_width,
|
int dst_width,
|
||||||
int scale);
|
int scale);
|
||||||
|
void ScaleRowDown2Linear_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale);
|
||||||
void ScaleRowDown2Box_C(const uint8_t* src_ptr,
|
void ScaleRowDown2Box_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
@ -305,6 +315,11 @@ void ScaleRowDown2Box_16To8_C(const uint16_t* src_ptr,
|
|||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
int dst_width,
|
int dst_width,
|
||||||
int scale);
|
int scale);
|
||||||
|
void ScaleRowDown2Box_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale);
|
||||||
void ScaleRowDown4_C(const uint8_t* src_ptr,
|
void ScaleRowDown4_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
|
|||||||
@ -211,13 +211,17 @@ void ScalePlaneDown2_16To8(int src_width,
|
|||||||
int y;
|
int y;
|
||||||
void (*ScaleRowDown2)(const uint16_t* src_ptr, ptrdiff_t src_stride,
|
void (*ScaleRowDown2)(const uint16_t* src_ptr, ptrdiff_t src_stride,
|
||||||
uint8_t* dst_ptr, int dst_width, int scale) =
|
uint8_t* dst_ptr, int dst_width, int scale) =
|
||||||
filtering == kFilterNone
|
(src_width & 1)
|
||||||
|
? (filtering == kFilterNone
|
||||||
|
? ScaleRowDown2_16To8_Odd_C
|
||||||
|
: (filtering == kFilterLinear ? ScaleRowDown2Linear_16To8_Odd_C
|
||||||
|
: ScaleRowDown2Box_16To8_Odd_C))
|
||||||
|
: (filtering == kFilterNone
|
||||||
? ScaleRowDown2_16To8_C
|
? ScaleRowDown2_16To8_C
|
||||||
: (filtering == kFilterLinear ? ScaleRowDown2Linear_16To8_C
|
: (filtering == kFilterLinear ? ScaleRowDown2Linear_16To8_C
|
||||||
: ScaleRowDown2Box_16To8_C);
|
: ScaleRowDown2Box_16To8_C));
|
||||||
int row_stride = src_stride * 2;
|
int row_stride = src_stride * 2;
|
||||||
(void)src_width;
|
(void)dst_height;
|
||||||
(void)src_height;
|
|
||||||
if (!filtering) {
|
if (!filtering) {
|
||||||
src_ptr += src_stride; // Point to odd rows.
|
src_ptr += src_stride; // Point to odd rows.
|
||||||
src_stride = 0;
|
src_stride = 0;
|
||||||
@ -226,12 +230,17 @@ void ScalePlaneDown2_16To8(int src_width,
|
|||||||
if (filtering == kFilterLinear) {
|
if (filtering == kFilterLinear) {
|
||||||
src_stride = 0;
|
src_stride = 0;
|
||||||
}
|
}
|
||||||
// TODO(fbarchard): Loop through source height to allow odd height.
|
for (y = 0; y < src_height / 2; ++y) {
|
||||||
for (y = 0; y < dst_height; ++y) {
|
|
||||||
ScaleRowDown2(src_ptr, src_stride, dst_ptr, dst_width, scale);
|
ScaleRowDown2(src_ptr, src_stride, dst_ptr, dst_width, scale);
|
||||||
src_ptr += row_stride;
|
src_ptr += row_stride;
|
||||||
dst_ptr += dst_stride;
|
dst_ptr += dst_stride;
|
||||||
}
|
}
|
||||||
|
if (src_height & 1) {
|
||||||
|
if (!filtering) {
|
||||||
|
src_ptr -= src_stride; // Point to last row.
|
||||||
|
}
|
||||||
|
ScaleRowDown2(src_ptr, 0, dst_ptr, dst_width, scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale plane, 1/4
|
// Scale plane, 1/4
|
||||||
|
|||||||
@ -101,6 +101,30 @@ void ScaleRowDown2_16To8_C(const uint16_t* src_ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScaleRowDown2_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale) {
|
||||||
|
int x;
|
||||||
|
(void)src_stride;
|
||||||
|
assert(scale >= 256);
|
||||||
|
assert(scale <= 32768);
|
||||||
|
dst_width -= 1;
|
||||||
|
for (x = 0; x < dst_width - 1; x += 2) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8(src_ptr[1], scale));
|
||||||
|
dst[1] = STATIC_CAST(uint8_t, C16TO8(src_ptr[3], scale));
|
||||||
|
dst += 2;
|
||||||
|
src_ptr += 4;
|
||||||
|
}
|
||||||
|
if (dst_width & 1) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8(src_ptr[1], scale));
|
||||||
|
dst += 1;
|
||||||
|
src_ptr += 2;
|
||||||
|
}
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8(src_ptr[0], scale));
|
||||||
|
}
|
||||||
|
|
||||||
void ScaleRowDown2Linear_C(const uint8_t* src_ptr,
|
void ScaleRowDown2Linear_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
@ -158,6 +182,31 @@ void ScaleRowDown2Linear_16To8_C(const uint16_t* src_ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScaleRowDown2Linear_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale) {
|
||||||
|
const uint16_t* s = src_ptr;
|
||||||
|
int x;
|
||||||
|
(void)src_stride;
|
||||||
|
assert(scale >= 256);
|
||||||
|
assert(scale <= 32768);
|
||||||
|
dst_width -= 1;
|
||||||
|
for (x = 0; x < dst_width - 1; x += 2) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8((s[0] + s[1] + 1) >> 1, scale));
|
||||||
|
dst[1] = STATIC_CAST(uint8_t, C16TO8((s[2] + s[3] + 1) >> 1, scale));
|
||||||
|
dst += 2;
|
||||||
|
s += 4;
|
||||||
|
}
|
||||||
|
if (dst_width & 1) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8((s[0] + s[1] + 1) >> 1, scale));
|
||||||
|
dst += 1;
|
||||||
|
s += 2;
|
||||||
|
}
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8(s[0], scale));
|
||||||
|
}
|
||||||
|
|
||||||
void ScaleRowDown2Box_C(const uint8_t* src_ptr,
|
void ScaleRowDown2Box_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
@ -245,6 +294,36 @@ void ScaleRowDown2Box_16To8_C(const uint16_t* src_ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScaleRowDown2Box_16To8_Odd_C(const uint16_t* src_ptr,
|
||||||
|
ptrdiff_t src_stride,
|
||||||
|
uint8_t* dst,
|
||||||
|
int dst_width,
|
||||||
|
int scale) {
|
||||||
|
const uint16_t* s = src_ptr;
|
||||||
|
const uint16_t* t = src_ptr + src_stride;
|
||||||
|
int x;
|
||||||
|
assert(scale >= 256);
|
||||||
|
assert(scale <= 32768);
|
||||||
|
dst_width -= 1;
|
||||||
|
for (x = 0; x < dst_width - 1; x += 2) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t,
|
||||||
|
C16TO8((s[0] + s[1] + t[0] + t[1] + 2) >> 2, scale));
|
||||||
|
dst[1] = STATIC_CAST(uint8_t,
|
||||||
|
C16TO8((s[2] + s[3] + t[2] + t[3] + 2) >> 2, scale));
|
||||||
|
dst += 2;
|
||||||
|
s += 4;
|
||||||
|
t += 4;
|
||||||
|
}
|
||||||
|
if (dst_width & 1) {
|
||||||
|
dst[0] = STATIC_CAST(uint8_t,
|
||||||
|
C16TO8((s[0] + s[1] + t[0] + t[1] + 2) >> 2, scale));
|
||||||
|
dst += 1;
|
||||||
|
s += 2;
|
||||||
|
t += 2;
|
||||||
|
}
|
||||||
|
dst[0] = STATIC_CAST(uint8_t, C16TO8((s[0] + t[0] + 1) >> 1, scale));
|
||||||
|
}
|
||||||
|
|
||||||
void ScaleRowDown4_C(const uint8_t* src_ptr,
|
void ScaleRowDown4_C(const uint8_t* src_ptr,
|
||||||
ptrdiff_t src_stride,
|
ptrdiff_t src_stride,
|
||||||
uint8_t* dst,
|
uint8_t* dst,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user