michael@0: /* michael@0: * Copyright (c) 2011 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: #ifndef LOOKAHEAD_H michael@0: #define LOOKAHEAD_H michael@0: #include "vpx_scale/yv12config.h" michael@0: #include "vpx/vpx_integer.h" michael@0: michael@0: struct lookahead_entry michael@0: { michael@0: YV12_BUFFER_CONFIG img; michael@0: int64_t ts_start; michael@0: int64_t ts_end; michael@0: unsigned int flags; michael@0: }; michael@0: michael@0: michael@0: struct lookahead_ctx; michael@0: michael@0: /**\brief Initializes the lookahead stage michael@0: * michael@0: * The lookahead stage is a queue of frame buffers on which some analysis michael@0: * may be done when buffers are enqueued. michael@0: * michael@0: * michael@0: */ michael@0: struct lookahead_ctx* vp8_lookahead_init(unsigned int width, michael@0: unsigned int height, michael@0: unsigned int depth michael@0: ); michael@0: michael@0: michael@0: /**\brief Destroys the lookahead stage michael@0: * michael@0: */ michael@0: void vp8_lookahead_destroy(struct lookahead_ctx *ctx); michael@0: michael@0: michael@0: /**\brief Enqueue a source buffer michael@0: * michael@0: * This function will copy the source image into a new framebuffer with michael@0: * the expected stride/border. michael@0: * michael@0: * If active_map is non-NULL and there is only one frame in the queue, then copy michael@0: * only active macroblocks. michael@0: * michael@0: * \param[in] ctx Pointer to the lookahead context michael@0: * \param[in] src Pointer to the image to enqueue michael@0: * \param[in] ts_start Timestamp for the start of this frame michael@0: * \param[in] ts_end Timestamp for the end of this frame michael@0: * \param[in] flags Flags set on this frame michael@0: * \param[in] active_map Map that specifies which macroblock is active michael@0: */ michael@0: int michael@0: vp8_lookahead_push(struct lookahead_ctx *ctx, michael@0: YV12_BUFFER_CONFIG *src, michael@0: int64_t ts_start, michael@0: int64_t ts_end, michael@0: unsigned int flags, michael@0: unsigned char *active_map); michael@0: michael@0: michael@0: /**\brief Get the next source buffer to encode michael@0: * michael@0: * michael@0: * \param[in] ctx Pointer to the lookahead context michael@0: * \param[in] drain Flag indicating the buffer should be drained michael@0: * (return a buffer regardless of the current queue depth) michael@0: * michael@0: * \retval NULL, if drain set and queue is empty michael@0: * \retval NULL, if drain not set and queue not of the configured depth michael@0: * michael@0: */ michael@0: struct lookahead_entry* michael@0: vp8_lookahead_pop(struct lookahead_ctx *ctx, michael@0: int drain); michael@0: michael@0: michael@0: #define PEEK_FORWARD 1 michael@0: #define PEEK_BACKWARD -1 michael@0: /**\brief Get a future source buffer to encode michael@0: * michael@0: * \param[in] ctx Pointer to the lookahead context michael@0: * \param[in] index Index of the frame to be returned, 0 == next frame michael@0: * michael@0: * \retval NULL, if no buffer exists at the specified index michael@0: * michael@0: */ michael@0: struct lookahead_entry* michael@0: vp8_lookahead_peek(struct lookahead_ctx *ctx, michael@0: unsigned int index, michael@0: int direction); michael@0: michael@0: michael@0: /**\brief Get the number of frames currently in the lookahead queue michael@0: * michael@0: * \param[in] ctx Pointer to the lookahead context michael@0: */ michael@0: unsigned int michael@0: vp8_lookahead_depth(struct lookahead_ctx *ctx); michael@0: michael@0: michael@0: #endif