[FFmpeg-devel] [PATCH 5/6] vp9: coef decoding context-splat speedup.
Ronald S. Bultje
rsbultje at gmail.com
Sat Feb 8 23:05:52 CET 2014
---
libavcodec/vp9.c | 52 ++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 317a5fb..54203ef 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -2134,11 +2134,44 @@ static void decode_coeffs(AVCodecContext *ctx)
}
}
}
- if (b->tx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += step1d)
- memset(&l[y + 1], l[y], FFMIN(end_y - y - 1, step1d - 1));
- for (x = 0; x < end_x; x += step1d)
- memset(&a[x + 1], a[x], FFMIN(end_x - x - 1, step1d - 1));
+#define SPLAT(la, end, step, cond) \
+ if (step == 2) { \
+ for (n = 1; n < end; n += step) \
+ la[n] = la[n - 1]; \
+ } else if (step == 4) { \
+ if (cond) { \
+ for (n = 0; n < end; n += step) \
+ AV_WN32A(&la[n], la[n] * 0x01010101); \
+ } else { \
+ for (n = 0; n < end; n += step) \
+ memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
+ } \
+ } else /* step == 8 */ { \
+ if (cond) { \
+ if (HAVE_FAST_64BIT) { \
+ for (n = 0; n < end; n += step) \
+ AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
+ } else { \
+ for (n = 0; n < end; n += step) { \
+ uint32_t v32 = la[n] * 0x01010101; \
+ AV_WN32A(&la[n], v32); \
+ AV_WN32A(&la[n + 4], v32); \
+ } \
+ } \
+ } else { \
+ for (n = 0; n < end; n += step) \
+ memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
+ } \
+ }
+#define SPLAT_CTX(step) \
+ do { \
+ SPLAT(a, end_x, step, end_x == w4); \
+ SPLAT(l, end_y, step, end_y == h4); \
+ } while (0)
+ switch (b->tx) {
+ case TX_8X8: SPLAT_CTX(2); break;
+ case TX_16X16: SPLAT_CTX(4); break;
+ case TX_32X32: SPLAT_CTX(8); break;
}
p = s->prob.coef[b->uvtx][1 /* uv */][!b->intra];
@@ -2170,11 +2203,10 @@ static void decode_coeffs(AVCodecContext *ctx)
}
}
}
- if (b->uvtx > TX_4X4) { // FIXME slow
- for (y = 0; y < end_y; y += uvstep1d)
- memset(&l[y + 1], l[y], FFMIN(end_y - y - 1, uvstep1d - 1));
- for (x = 0; x < end_x; x += uvstep1d)
- memset(&a[x + 1], a[x], FFMIN(end_x - x - 1, uvstep1d - 1));
+ switch (b->uvtx) {
+ case TX_8X8: SPLAT_CTX(2); break;
+ case TX_16X16: SPLAT_CTX(4); break;
+ case TX_32X32: SPLAT_CTX(8); break;
}
}
}
--
1.8.4
More information about the ffmpeg-devel
mailing list