vp9_lookahead.h 3.19 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1 2 3 4 5 6 7 8 9
/*
 *  Copyright (c) 2011 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
10

11 12
#ifndef VP9_ENCODER_VP9_LOOKAHEAD_H_
#define VP9_ENCODER_VP9_LOOKAHEAD_H_
13

John Koleszar's avatar
John Koleszar committed
14 15 16
#include "vpx_scale/yv12config.h"
#include "vpx/vpx_integer.h"

John Koleszar's avatar
John Koleszar committed
17 18 19 20 21
struct lookahead_entry {
  YV12_BUFFER_CONFIG  img;
  int64_t             ts_start;
  int64_t             ts_end;
  unsigned int        flags;
John Koleszar's avatar
John Koleszar committed
22 23 24 25 26 27 28 29 30 31
};


struct lookahead_ctx;

/**\brief Initializes the lookahead stage
 *
 * The lookahead stage is a queue of frame buffers on which some analysis
 * may be done when buffers are enqueued.
 */
32
struct lookahead_ctx *vp9_lookahead_init(unsigned int width,
John Koleszar's avatar
John Koleszar committed
33
                                         unsigned int height,
34 35
                                         unsigned int subsampling_x,
                                         unsigned int subsampling_y,
Dmitry Kovalev's avatar
Dmitry Kovalev committed
36
                                         unsigned int depth);
John Koleszar's avatar
John Koleszar committed
37 38 39 40


/**\brief Destroys the lookahead stage
 */
41
void vp9_lookahead_destroy(struct lookahead_ctx *ctx);
John Koleszar's avatar
John Koleszar committed
42 43 44 45 46 47 48


/**\brief Enqueue a source buffer
 *
 * This function will copy the source image into a new framebuffer with
 * the expected stride/border.
 *
49 50 51 52 53 54 55 56 57
 * If active_map is non-NULL and there is only one frame in the queue, then copy
 * only active macroblocks.
 *
 * \param[in] ctx         Pointer to the lookahead context
 * \param[in] src         Pointer to the image to enqueue
 * \param[in] ts_start    Timestamp for the start of this frame
 * \param[in] ts_end      Timestamp for the end of this frame
 * \param[in] flags       Flags set on this frame
 * \param[in] active_map  Map that specifies which macroblock is active
John Koleszar's avatar
John Koleszar committed
58
 */
Dmitry Kovalev's avatar
Dmitry Kovalev committed
59 60 61
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);
John Koleszar's avatar
John Koleszar committed
62 63 64 65 66 67 68 69 70 71 72 73


/**\brief Get the next source buffer to encode
 *
 *
 * \param[in] ctx       Pointer to the lookahead context
 * \param[in] drain     Flag indicating the buffer should be drained
 *                      (return a buffer regardless of the current queue depth)
 *
 * \retval NULL, if drain set and queue is empty
 * \retval NULL, if drain not set and queue not of the configured depth
 */
Dmitry Kovalev's avatar
Dmitry Kovalev committed
74 75
struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
                                          int drain);
John Koleszar's avatar
John Koleszar committed
76 77 78 79 80 81 82 83 84


/**\brief Get a future source buffer to encode
 *
 * \param[in] ctx       Pointer to the lookahead context
 * \param[in] index     Index of the frame to be returned, 0 == next frame
 *
 * \retval NULL, if no buffer exists at the specified index
 */
Dmitry Kovalev's avatar
Dmitry Kovalev committed
85 86
struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
                                           int index);
John Koleszar's avatar
John Koleszar committed
87 88 89 90 91 92


/**\brief Get the number of frames currently in the lookahead queue
 *
 * \param[in] ctx       Pointer to the lookahead context
 */
Dmitry Kovalev's avatar
Dmitry Kovalev committed
93
unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
John Koleszar's avatar
John Koleszar committed
94

95
#endif  // VP9_ENCODER_VP9_LOOKAHEAD_H_