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 #include "vp9/common/vp9_common.h" | 15 #include "vp9/common/vp9_common.h" |
| 16 |
15 #include "vp9/encoder/vp9_extend.h" | 17 #include "vp9/encoder/vp9_extend.h" |
16 #include "vp9/encoder/vp9_lookahead.h" | 18 #include "vp9/encoder/vp9_lookahead.h" |
| 19 #include "vp9/encoder/vp9_onyx_int.h" |
17 | 20 |
18 struct lookahead_ctx { | 21 struct lookahead_ctx { |
19 unsigned int max_sz; /* Absolute size of the queue */ | 22 unsigned int max_sz; /* Absolute size of the queue */ |
20 unsigned int sz; /* Number of buffers currently in the queue */ | 23 unsigned int sz; /* Number of buffers currently in the queue */ |
21 unsigned int read_idx; /* Read index */ | 24 unsigned int read_idx; /* Read index */ |
22 unsigned int write_idx; /* Write index */ | 25 unsigned int write_idx; /* Write index */ |
23 struct lookahead_entry *buf; /* Buffer list */ | 26 struct lookahead_entry *buf; /* Buffer list */ |
24 }; | 27 }; |
25 | 28 |
26 | 29 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ctx->sz--; | 169 ctx->sz--; |
167 } | 170 } |
168 return buf; | 171 return buf; |
169 } | 172 } |
170 | 173 |
171 | 174 |
172 struct lookahead_entry * vp9_lookahead_peek(struct lookahead_ctx *ctx, | 175 struct lookahead_entry * vp9_lookahead_peek(struct lookahead_ctx *ctx, |
173 int index) { | 176 int index) { |
174 struct lookahead_entry *buf = NULL; | 177 struct lookahead_entry *buf = NULL; |
175 | 178 |
176 assert(index < (int)ctx->max_sz); | |
177 if (index < (int)ctx->sz) { | 179 if (index < (int)ctx->sz) { |
178 index += ctx->read_idx; | 180 index += ctx->read_idx; |
179 if (index >= (int)ctx->max_sz) | 181 if (index >= (int)ctx->max_sz) |
180 index -= ctx->max_sz; | 182 index -= ctx->max_sz; |
181 buf = ctx->buf + index; | 183 buf = ctx->buf + index; |
182 } | 184 } |
183 return buf; | 185 return buf; |
184 } | 186 } |
185 | 187 |
186 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) { | 188 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) { |
187 return ctx->sz; | 189 return ctx->sz; |
188 } | 190 } |
OLD | NEW |