summaryrefslogtreecommitdiff
path: root/vp8/encoder/lookahead.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/lookahead.c')
-rw-r--r--vp8/encoder/lookahead.c57
1 files changed, 55 insertions, 2 deletions
diff --git a/vp8/encoder/lookahead.c b/vp8/encoder/lookahead.c
index d7f85cba1..b92e82bdf 100644
--- a/vp8/encoder/lookahead.c
+++ b/vp8/encoder/lookahead.c
@@ -102,15 +102,68 @@ vp8_lookahead_push(struct lookahead_ctx *ctx,
YV12_BUFFER_CONFIG *src,
int64_t ts_start,
int64_t ts_end,
- unsigned int flags)
+ unsigned int flags,
+ unsigned char *active_map)
{
struct lookahead_entry* buf;
+ int row, col, active_end;
+ int mb_rows = (src->y_height + 15) >> 4;
+ int mb_cols = (src->y_width + 15) >> 4;
if(ctx->sz + 1 > ctx->max_sz)
return 1;
ctx->sz++;
buf = pop(ctx, &ctx->write_idx);
- vp8_copy_and_extend_frame(src, &buf->img);
+
+ // Only do this partial copy if the following conditions are all met:
+ // 1. Lookahead queue has has size of 1.
+ // 2. Active map is provided.
+ // 3. This is not a key frame, golden nor altref frame.
+ if (ctx->max_sz == 1 && active_map && !flags)
+ {
+ for (row = 0; row < mb_rows; ++row)
+ {
+ col = 0;
+
+ while (1)
+ {
+ // Find the first active macroblock in this row.
+ for (; col < mb_cols; ++col)
+ {
+ if (active_map[col])
+ break;
+ }
+
+ // No more active macroblock in this row.
+ if (col == mb_cols)
+ break;
+
+ // Find the end of active region in this row.
+ active_end = col;
+
+ for (; active_end < mb_cols; ++active_end)
+ {
+ if (!active_map[active_end])
+ break;
+ }
+
+ // Only copy this active region.
+ vp8_copy_and_extend_frame_with_rect(src, &buf->img,
+ row << 4,
+ col << 4, 16,
+ (active_end - col) << 4);
+
+ // Start again from the end of this active region.
+ col = active_end;
+ }
+
+ active_map += mb_cols;
+ }
+ }
+ else
+ {
+ vp8_copy_and_extend_frame(src, &buf->img);
+ }
buf->ts_start = ts_start;
buf->ts_end = ts_end;
buf->flags = flags;