mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 20:19:55 +00:00
avfilter/showcqt: remove yuv offset
this makes draw_bar faster slightly different result with old version check result (with ~3 minutes audio file): old: real 0m49.611s user 0m49.260s sys 0m0.073s new: real 0m47.606s user 0m47.378s sys 0m0.068s PSNR between old and new: yuv444p PSNR y:109.519298 u:107.506485 v:104.746878 average:106.816074 min:99.167305 max:inf yuv422p PSNR y:109.519298 u:108.025801 v:104.489734 average:107.279817 min:98.007467 max:inf yuv420p PSNR y:109.519298 u:108.363875 v:105.290200 average:108.261511 min:97.461812 max:inf Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
92e483f8ed
commit
6df2c94130
@ -679,9 +679,9 @@ static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int le
|
||||
r = calculate_gamma(FFMIN(1.0f, v[x].re), gamma);
|
||||
g = calculate_gamma(FFMIN(1.0f, 0.5f * (v[x].re + v[x].im)), gamma);
|
||||
b = calculate_gamma(FFMIN(1.0f, v[x].im), gamma);
|
||||
c[x].yuv.y = 16.0f + 65.481f * r + 128.553f * g + 24.966f * b;
|
||||
c[x].yuv.u = 128.0f - 37.797f * r - 74.203f * g + 112.0f * b;
|
||||
c[x].yuv.v = 128.0f + 112.0f * r - 93.786f * g - 18.214 * b;
|
||||
c[x].yuv.y = 65.481f * r + 128.553f * g + 24.966f * b;
|
||||
c[x].yuv.u = -37.797f * r - 74.203f * g + 112.0f * b;
|
||||
c[x].yuv.v = 112.0f * r - 93.786f * g - 18.214 * b;
|
||||
}
|
||||
}
|
||||
|
||||
@ -734,9 +734,9 @@ static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
|
||||
*lpv++ = 128;
|
||||
} else {
|
||||
mul = (h[x] - ht) * rcp_h[x];
|
||||
*lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpy++ = mul * c[x].yuv.y + 16.5f;
|
||||
*lpu++ = mul * c[x].yuv.u + 128.5f;
|
||||
*lpv++ = mul * c[x].yuv.v + 128.5f;
|
||||
}
|
||||
/* u and v are skipped on yuv422p and yuv420p */
|
||||
if (fmt == AV_PIX_FMT_YUV444P) {
|
||||
@ -746,16 +746,16 @@ static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
|
||||
*lpv++ = 128;
|
||||
} else {
|
||||
mul = (h[x+1] - ht) * rcp_h[x+1];
|
||||
*lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpy++ = mul * c[x+1].yuv.y + 16.5f;
|
||||
*lpu++ = mul * c[x+1].yuv.u + 128.5f;
|
||||
*lpv++ = mul * c[x+1].yuv.v + 128.5f;
|
||||
}
|
||||
} else {
|
||||
if (h[x+1] <= ht) {
|
||||
*lpy++ = 16;
|
||||
} else {
|
||||
mul = (h[x+1] - ht) * rcp_h[x+1];
|
||||
*lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpy++ = mul * c[x+1].yuv.y + 16.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -773,16 +773,16 @@ static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
|
||||
*lpv++ = 128;
|
||||
} else {
|
||||
mul = (h[x] - ht) * rcp_h[x];
|
||||
*lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpu++ = mul * c[x].yuv.u + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpv++ = mul * c[x].yuv.v + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpy++ = mul * c[x].yuv.y + 16.5f;
|
||||
*lpu++ = mul * c[x].yuv.u + 128.5f;
|
||||
*lpv++ = mul * c[x].yuv.v + 128.5f;
|
||||
}
|
||||
} else {
|
||||
if (h[x] <= ht) {
|
||||
*lpy++ = 16;
|
||||
} else {
|
||||
mul = (h[x] - ht) * rcp_h[x];
|
||||
*lpy++ = mul * c[x].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpy++ = mul * c[x].yuv.y + 16.5f;
|
||||
}
|
||||
}
|
||||
/* u and v are skipped on yuv422p and yuv420p */
|
||||
@ -793,16 +793,16 @@ static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
|
||||
*lpv++ = 128;
|
||||
} else {
|
||||
mul = (h[x+1] - ht) * rcp_h[x+1];
|
||||
*lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpu++ = mul * c[x+1].yuv.u + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpv++ = mul * c[x+1].yuv.v + (1.0f - mul) * 128.0f + 0.5f;
|
||||
*lpy++ = mul * c[x+1].yuv.y + 16.5f;
|
||||
*lpu++ = mul * c[x+1].yuv.u + 128.5f;
|
||||
*lpv++ = mul * c[x+1].yuv.v + 128.5f;
|
||||
}
|
||||
} else {
|
||||
if (h[x+1] <= ht) {
|
||||
*lpy++ = 16;
|
||||
} else {
|
||||
mul = (h[x+1] - ht) * rcp_h[x+1];
|
||||
*lpy++ = mul * c[x+1].yuv.y + (1.0f - mul) * 16.0f + 0.5f;
|
||||
*lpy++ = mul * c[x+1].yuv.y + 16.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -850,15 +850,15 @@ static void draw_axis_yuv(AVFrame *out, AVFrame *axis, const ColorFloat *c, int
|
||||
lpaa = vaa + y * lsaa;
|
||||
for (x = 0; x < w; x += 2) {
|
||||
a = rcp_255 * (*lpaa++);
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * c[x].yuv.y + 0.5f;
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * c[x].yuv.u + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * c[x].yuv.v + 0.5f;
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * (c[x].yuv.y + 16.0f) + 0.5f;
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * (c[x].yuv.u + 128.0f) + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * (c[x].yuv.v + 128.0f) + 0.5f;
|
||||
/* u and v are skipped on yuv422p and yuv420p */
|
||||
a = rcp_255 * (*lpaa++);
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * c[x+1].yuv.y + 0.5f;
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * (c[x+1].yuv.y + 16.0f) + 0.5f;
|
||||
if (fmt == AV_PIX_FMT_YUV444P) {
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * c[x+1].yuv.u + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * c[x+1].yuv.v + 0.5f;
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * (c[x+1].yuv.u + 128.0f) + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * (c[x+1].yuv.v + 128.0f) + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -872,17 +872,17 @@ static void draw_axis_yuv(AVFrame *out, AVFrame *axis, const ColorFloat *c, int
|
||||
for (x = 0; x < out->width; x += 2) {
|
||||
/* u and v are skipped on yuv420p */
|
||||
a = rcp_255 * (*lpaa++);
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * c[x].yuv.y + 0.5f;
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * (c[x].yuv.y + 16.0f) + 0.5f;
|
||||
if (fmt != AV_PIX_FMT_YUV420P) {
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * c[x].yuv.u + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * c[x].yuv.v + 0.5f;
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * (c[x].yuv.u + 128.0f) + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * (c[x].yuv.v + 128.0f) + 0.5f;
|
||||
}
|
||||
/* u and v are skipped on yuv422p and yuv420p */
|
||||
a = rcp_255 * (*lpaa++);
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * c[x+1].yuv.y + 0.5f;
|
||||
*lpy++ = a * (*lpay++) + (1.0f - a) * (c[x+1].yuv.y + 16.0f) + 0.5f;
|
||||
if (fmt == AV_PIX_FMT_YUV444P) {
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * c[x+1].yuv.u + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * c[x+1].yuv.v + 0.5f;
|
||||
*lpu++ = a * (*lpau++) + (1.0f - a) * (c[x+1].yuv.u + 128.0f) + 0.5f;
|
||||
*lpv++ = a * (*lpav++) + (1.0f - a) * (c[x+1].yuv.v + 128.0f) + 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -932,13 +932,13 @@ static void update_sono_yuv(AVFrame *sono, const ColorFloat *c, int idx)
|
||||
uint8_t *lpv = sono->data[2] + idx * sono->linesize[2];
|
||||
|
||||
for (x = 0; x < w; x += 2) {
|
||||
*lpy++ = c[x].yuv.y + 0.5f;
|
||||
*lpu++ = c[x].yuv.u + 0.5f;
|
||||
*lpv++ = c[x].yuv.v + 0.5f;
|
||||
*lpy++ = c[x+1].yuv.y + 0.5f;
|
||||
*lpy++ = c[x].yuv.y + 16.5f;
|
||||
*lpu++ = c[x].yuv.u + 128.5f;
|
||||
*lpv++ = c[x].yuv.v + 128.5f;
|
||||
*lpy++ = c[x+1].yuv.y + 16.5f;
|
||||
if (fmt == AV_PIX_FMT_YUV444P) {
|
||||
*lpu++ = c[x+1].yuv.u + 0.5f;
|
||||
*lpv++ = c[x+1].yuv.v + 0.5f;
|
||||
*lpu++ = c[x+1].yuv.u + 128.5f;
|
||||
*lpv++ = c[x+1].yuv.v + 128.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user