1/* 2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10#ifndef VP8_ENCODER_LOOKAHEAD_H_ 11#define VP8_ENCODER_LOOKAHEAD_H_ 12#include "vpx_scale/yv12config.h" 13#include "vpx/vpx_integer.h" 14 15#ifdef __cplusplus 16extern "C" { 17#endif 18 19struct lookahead_entry 20{ 21 YV12_BUFFER_CONFIG img; 22 int64_t ts_start; 23 int64_t ts_end; 24 unsigned int flags; 25}; 26 27 28struct lookahead_ctx; 29 30/**\brief Initializes the lookahead stage 31 * 32 * The lookahead stage is a queue of frame buffers on which some analysis 33 * may be done when buffers are enqueued. 34 * 35 * 36 */ 37struct lookahead_ctx* vp8_lookahead_init(unsigned int width, 38 unsigned int height, 39 unsigned int depth 40 ); 41 42 43/**\brief Destroys the lookahead stage 44 * 45 */ 46void vp8_lookahead_destroy(struct lookahead_ctx *ctx); 47 48 49/**\brief Enqueue a source buffer 50 * 51 * This function will copy the source image into a new framebuffer with 52 * the expected stride/border. 53 * 54 * If active_map is non-NULL and there is only one frame in the queue, then copy 55 * only active macroblocks. 56 * 57 * \param[in] ctx Pointer to the lookahead context 58 * \param[in] src Pointer to the image to enqueue 59 * \param[in] ts_start Timestamp for the start of this frame 60 * \param[in] ts_end Timestamp for the end of this frame 61 * \param[in] flags Flags set on this frame 62 * \param[in] active_map Map that specifies which macroblock is active 63 */ 64int 65vp8_lookahead_push(struct lookahead_ctx *ctx, 66 YV12_BUFFER_CONFIG *src, 67 int64_t ts_start, 68 int64_t ts_end, 69 unsigned int flags, 70 unsigned char *active_map); 71 72 73/**\brief Get the next source buffer to encode 74 * 75 * 76 * \param[in] ctx Pointer to the lookahead context 77 * \param[in] drain Flag indicating the buffer should be drained 78 * (return a buffer regardless of the current queue depth) 79 * 80 * \retval NULL, if drain set and queue is empty 81 * \retval NULL, if drain not set and queue not of the configured depth 82 * 83 */ 84struct lookahead_entry* 85vp8_lookahead_pop(struct lookahead_ctx *ctx, 86 int drain); 87 88 89#define PEEK_FORWARD 1 90#define PEEK_BACKWARD -1 91/**\brief Get a future source buffer to encode 92 * 93 * \param[in] ctx Pointer to the lookahead context 94 * \param[in] index Index of the frame to be returned, 0 == next frame 95 * 96 * \retval NULL, if no buffer exists at the specified index 97 * 98 */ 99struct lookahead_entry* 100vp8_lookahead_peek(struct lookahead_ctx *ctx, 101 unsigned int index, 102 int direction); 103 104 105/**\brief Get the number of frames currently in the lookahead queue 106 * 107 * \param[in] ctx Pointer to the lookahead context 108 */ 109unsigned int 110vp8_lookahead_depth(struct lookahead_ctx *ctx); 111 112 113#ifdef __cplusplus 114} // extern "C" 115#endif 116 117#endif // VP8_ENCODER_LOOKAHEAD_H_ 118