OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include <assert.h> | 10 #include <assert.h> |
11 #include <stdlib.h> | 11 #include <stdlib.h> |
12 | 12 |
13 #include "./vpx_config.h" | 13 #include "./vpx_config.h" |
14 | 14 |
15 #include "vp9/common/vp9_common.h" | 15 #include "vp9/common/vp9_common.h" |
16 | 16 |
17 #include "vp9/encoder/vp9_encoder.h" | 17 #include "vp9/encoder/vp9_encoder.h" |
18 #include "vp9/encoder/vp9_extend.h" | 18 #include "vp9/encoder/vp9_extend.h" |
19 #include "vp9/encoder/vp9_lookahead.h" | 19 #include "vp9/encoder/vp9_lookahead.h" |
20 | 20 |
21 // The max of past frames we want to keep in the queue. | |
22 #define MAX_PRE_FRAMES 1 | |
23 | |
24 struct lookahead_ctx { | |
25 unsigned int max_sz; /* Absolute size of the queue */ | |
26 unsigned int sz; /* Number of buffers currently in the queue */ | |
27 unsigned int read_idx; /* Read index */ | |
28 unsigned int write_idx; /* Write index */ | |
29 struct lookahead_entry *buf; /* Buffer list */ | |
30 }; | |
31 | |
32 | |
33 /* Return the buffer at the given absolute index and increment the index */ | 21 /* Return the buffer at the given absolute index and increment the index */ |
34 static struct lookahead_entry *pop(struct lookahead_ctx *ctx, | 22 static struct lookahead_entry *pop(struct lookahead_ctx *ctx, |
35 unsigned int *idx) { | 23 unsigned int *idx) { |
36 unsigned int index = *idx; | 24 unsigned int index = *idx; |
37 struct lookahead_entry *buf = ctx->buf + index; | 25 struct lookahead_entry *buf = ctx->buf + index; |
38 | 26 |
39 assert(index < ctx->max_sz); | 27 assert(index < ctx->max_sz); |
40 if (++index >= ctx->max_sz) | 28 if (++index >= ctx->max_sz) |
41 index -= ctx->max_sz; | 29 index -= ctx->max_sz; |
42 *idx = index; | 30 *idx = index; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 buf = ctx->buf + index; | 186 buf = ctx->buf + index; |
199 } | 187 } |
200 } | 188 } |
201 | 189 |
202 return buf; | 190 return buf; |
203 } | 191 } |
204 | 192 |
205 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) { | 193 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) { |
206 return ctx->sz; | 194 return ctx->sz; |
207 } | 195 } |
OLD | NEW |