Commit ff553ba1 authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review
Browse files

Merge "Code cleanup." into experimental

parents a07eb47b 2891d70b
......@@ -51,4 +51,8 @@ static INLINE uint8_t clip_pixel(int val) {
return (val > 255) ? 255u : (val < 0) ? 0u : val;
}
static INLINE int clamp(int value, int low, int high) {
return value < low ? low : (value > high ? high : value);
}
#endif // VP9_COMMON_VP9_COMMON_H_
This diff is collapsed.
......@@ -9,7 +9,9 @@
*/
#include <assert.h>
#include <stdlib.h>
#include "vpx_config.h"
#include "vp9/common/vp9_common.h"
#include "vp9/encoder/vp9_lookahead.h"
#include "vp9/common/vp9_extend.h"
......@@ -25,10 +27,9 @@ struct lookahead_ctx {
/* Return the buffer at the given absolute index and increment the index */
static struct lookahead_entry *
pop(struct lookahead_ctx *ctx,
unsigned int *idx) {
unsigned int index = *idx;
static struct lookahead_entry * pop(struct lookahead_ctx *ctx,
unsigned int *idx) {
unsigned int index = *idx;
struct lookahead_entry *buf = ctx->buf + index;
assert(index < ctx->max_sz);
......@@ -39,8 +40,7 @@ pop(struct lookahead_ctx *ctx,
}
void
vp9_lookahead_destroy(struct lookahead_ctx *ctx) {
void vp9_lookahead_destroy(struct lookahead_ctx *ctx) {
if (ctx) {
if (ctx->buf) {
unsigned int i;
......@@ -54,23 +54,19 @@ vp9_lookahead_destroy(struct lookahead_ctx *ctx) {
}
struct lookahead_ctx *
vp9_lookahead_init(unsigned int width,
unsigned int height,
unsigned int depth) {
struct lookahead_ctx * vp9_lookahead_init(unsigned int width,
unsigned int height,
unsigned int depth) {
struct lookahead_ctx *ctx = NULL;
/* Clamp the lookahead queue depth */
if (depth < 1)
depth = 1;
else if (depth > MAX_LAG_BUFFERS)
depth = MAX_LAG_BUFFERS;
// Clamp the lookahead queue depth
depth = clamp(depth, 1, MAX_LAG_BUFFERS);
/* Align the buffer dimensions */
// Align the buffer dimensions
width = (width + 15) &~15;
height = (height + 15) &~15;
/* Allocate the lookahead structures */
// Allocate the lookahead structures
ctx = calloc(1, sizeof(*ctx));
if (ctx) {
unsigned int i;
......@@ -90,13 +86,9 @@ bail:
}
int
vp9_lookahead_push(struct lookahead_ctx *ctx,
YV12_BUFFER_CONFIG *src,
int64_t ts_start,
int64_t ts_end,
unsigned int flags,
unsigned char *active_map) {
int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
int64_t ts_start, int64_t ts_end, unsigned int flags,
unsigned char *active_map) {
struct lookahead_entry *buf;
int row, col, active_end;
int mb_rows = (src->y_height + 15) >> 4;
......@@ -156,9 +148,8 @@ vp9_lookahead_push(struct lookahead_ctx *ctx,
}
struct lookahead_entry *
vp9_lookahead_pop(struct lookahead_ctx *ctx,
int drain) {
struct lookahead_entry * vp9_lookahead_pop(struct lookahead_ctx *ctx,
int drain) {
struct lookahead_entry *buf = NULL;
if (ctx->sz && (drain || ctx->sz == ctx->max_sz)) {
......@@ -169,9 +160,8 @@ vp9_lookahead_pop(struct lookahead_ctx *ctx,
}
struct lookahead_entry *
vp9_lookahead_peek(struct lookahead_ctx *ctx,
int index) {
struct lookahead_entry * vp9_lookahead_peek(struct lookahead_ctx *ctx,
int index) {
struct lookahead_entry *buf = NULL;
assert(index < (int)ctx->max_sz);
......@@ -184,8 +174,6 @@ vp9_lookahead_peek(struct lookahead_ctx *ctx,
return buf;
}
unsigned int
vp9_lookahead_depth(struct lookahead_ctx *ctx) {
unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx) {
return ctx->sz;
}
......@@ -28,17 +28,13 @@ struct lookahead_ctx;
*
* The lookahead stage is a queue of frame buffers on which some analysis
* may be done when buffers are enqueued.
*
*
*/
struct lookahead_ctx *vp9_lookahead_init(unsigned int width,
unsigned int height,
unsigned int depth
);
unsigned int depth);
/**\brief Destroys the lookahead stage
*
*/
void vp9_lookahead_destroy(struct lookahead_ctx *ctx);
......@@ -58,13 +54,9 @@ void vp9_lookahead_destroy(struct lookahead_ctx *ctx);
* \param[in] flags Flags set on this frame
* \param[in] active_map Map that specifies which macroblock is active
*/
int
vp9_lookahead_push(struct lookahead_ctx *ctx,
YV12_BUFFER_CONFIG *src,
int64_t ts_start,
int64_t ts_end,
unsigned int flags,
unsigned char *active_map);
int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
int64_t ts_start, int64_t ts_end, unsigned int flags,
unsigned char *active_map);
/**\brief Get the next source buffer to encode
......@@ -76,11 +68,9 @@ vp9_lookahead_push(struct lookahead_ctx *ctx,
*
* \retval NULL, if drain set and queue is empty
* \retval NULL, if drain not set and queue not of the configured depth
*
*/
struct lookahead_entry *
vp9_lookahead_pop(struct lookahead_ctx *ctx,
int drain);
struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
int drain);
/**\brief Get a future source buffer to encode
......@@ -89,18 +79,15 @@ vp9_lookahead_pop(struct lookahead_ctx *ctx,
* \param[in] index Index of the frame to be returned, 0 == next frame
*
* \retval NULL, if no buffer exists at the specified index
*
*/
struct lookahead_entry *
vp9_lookahead_peek(struct lookahead_ctx *ctx,
int index);
struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
int index);
/**\brief Get the number of frames currently in the lookahead queue
*
* \param[in] ctx Pointer to the lookahead context
*/
unsigned int
vp9_lookahead_depth(struct lookahead_ctx *ctx);
unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
#endif // VP9_ENCODER_VP9_LOOKAHEAD_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment