Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-14 20:19:06 +0400
committerMichael Niedermayer <michaelni@gmx.at>2011-11-14 21:29:29 +0400
commit75c0ddc9c2d5c60499cca8f82eac5865bcd57fd1 (patch)
treec956aee8e13b2910213f03f585895ab5453de5cb /libavcodec/vble.c
parent6718536ba500d8a471bae3849f124da892936c70 (diff)
vble: move 2nd pass bitreading into vble_restore_plane()
this improves data cache hits and speeds up grayscale only decoding Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vble.c')
-rw-r--r--libavcodec/vble.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index b27ec32a38..2a1cdae81b 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -73,18 +73,11 @@ static int vble_unpack(VBLEContext *ctx, GetBitContext *gb)
/* Check we have enough bits left */
if (get_bits_left(gb) < allbits)
return -1;
-
- for (i = 0; i < ctx->size; i++) {
- /* get_bits can't take a length of 0 */
- if (ctx->val[i])
- ctx->val[i] = (1 << ctx->val[i]) + get_bits(gb, ctx->val[i]) - 1;
- }
-
return 0;
}
-static void vble_restore_plane(VBLEContext *ctx, int plane, int offset,
- int width, int height)
+static void vble_restore_plane(VBLEContext *ctx, GetBitContext *gb, int plane,
+ int offset, int width, int height)
{
AVFrame *pic = ctx->avctx->coded_frame;
uint8_t *dst = pic->data[plane];
@@ -95,7 +88,12 @@ static void vble_restore_plane(VBLEContext *ctx, int plane, int offset,
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
- dst[j] = (val[j] >> 1) ^ -(val[j] & 1);
+ /* get_bits can't take a length of 0 */
+ if (val[j]) {
+ int v = (1 << val[j]) + get_bits(gb, val[j]) - 1;
+ val[j] = (v >> 1) ^ -(v & 1);
+ }
+ dst[j] = val[j];
/* Top line and left column are not predicted */
if (!j)
@@ -160,15 +158,15 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
/* Restore planes. Should be almost identical to Huffyuv's. */
- vble_restore_plane(ctx, 0, offset, avctx->width, avctx->height);
+ vble_restore_plane(ctx, &gb, 0, offset, avctx->width, avctx->height);
/* Chroma */
if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
offset += avctx->width * avctx->height;
- vble_restore_plane(ctx, 1, offset, width_uv, height_uv);
+ vble_restore_plane(ctx, &gb, 1, offset, width_uv, height_uv);
offset += width_uv * height_uv;
- vble_restore_plane(ctx, 2, offset, width_uv, height_uv);
+ vble_restore_plane(ctx, &gb, 2, offset, width_uv, height_uv);
}
*data_size = sizeof(AVFrame);