修bug
Some checks are pending
CI / host-build (push) Waiting to run
CI / rk3588-cross-build (push) Waiting to run

This commit is contained in:
sladro 2026-01-05 18:00:05 +08:00
parent 655e07da86
commit 05b8b0319c
2 changed files with 20 additions and 8 deletions

View File

@ -120,13 +120,17 @@ bool FillYuv420pFromFrame(const Frame& src, int width, int height, AVFrame* dst)
if (!s) return false;
const int s_stride = PlaneStride(src, 0, width * 3);
const int uv_w = width / 2;
const int uv_h = height / 2;
for (int row = 0; row < height; row += 2) {
const uint8_t* row0 = s + row * s_stride;
const uint8_t* row1 = (row + 1 < height) ? (s + (row + 1) * s_stride) : row0;
uint8_t* y0 = y + row * y_stride;
uint8_t* y1 = (row + 1 < height) ? (y + (row + 1) * y_stride) : y0;
uint8_t* uu = u + (row / 2) * u_stride;
uint8_t* vv = v + (row / 2) * v_stride;
const int uv_row = row / 2;
uint8_t* uu = (uv_row < uv_h) ? (u + uv_row * u_stride) : nullptr;
uint8_t* vv = (uv_row < uv_h) ? (v + uv_row * v_stride) : nullptr;
for (int col = 0; col < width; col += 2) {
int u_sum = 0;
@ -163,8 +167,10 @@ bool FillYuv420pFromFrame(const Frame& src, int width, int height, AVFrame* dst)
const int u_val = ((u_sum / denom) + 128 * 256 + 128) >> 8;
const int v_val = ((v_sum / denom) + 128 * 256 + 128) >> 8;
const int uv_col = col / 2;
uu[uv_col] = ClipU8(u_val);
vv[uv_col] = ClipU8(v_val);
if (uu && vv && uv_col >= 0 && uv_col < uv_w) {
uu[uv_col] = ClipU8(u_val);
vv[uv_col] = ClipU8(v_val);
}
}
}
return true;

View File

@ -118,13 +118,17 @@ bool FillYuv420pFromFrame(const Frame& src, AVFrame* dst) {
if (!s) return false;
const int s_stride = PlaneStride(src, 0, w * 3);
const int uv_w = w / 2;
const int uv_h = h / 2;
for (int row = 0; row < h; row += 2) {
const uint8_t* row0 = s + row * s_stride;
const uint8_t* row1 = (row + 1 < h) ? (s + (row + 1) * s_stride) : row0;
uint8_t* y0 = y + row * y_stride;
uint8_t* y1 = (row + 1 < h) ? (y + (row + 1) * y_stride) : y0;
uint8_t* uu = u + (row / 2) * u_stride;
uint8_t* vv = v + (row / 2) * v_stride;
const int uv_row = row / 2;
uint8_t* uu = (uv_row < uv_h) ? (u + uv_row * u_stride) : nullptr;
uint8_t* vv = (uv_row < uv_h) ? (v + uv_row * v_stride) : nullptr;
for (int col = 0; col < w; col += 2) {
int u_sum = 0;
@ -162,8 +166,10 @@ bool FillYuv420pFromFrame(const Frame& src, AVFrame* dst) {
const int u_val = ((u_sum / denom) + 128 * 256 + 128) >> 8;
const int v_val = ((v_sum / denom) + 128 * 256 + 128) >> 8;
const int uv_col = col / 2;
uu[uv_col] = ClipU8(u_val);
vv[uv_col] = ClipU8(v_val);
if (uu && vv && uv_col >= 0 && uv_col < uv_w) {
uu[uv_col] = ClipU8(u_val);
vv[uv_col] = ClipU8(v_val);
}
}
}
return true;