2011-04-13 22:00:18 +04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-12-19 03:31:19 +04:00
|
|
|
|
2012-11-30 04:36:10 +04:00
|
|
|
#ifndef VP9_ENCODER_VP9_LOOKAHEAD_H_
|
|
|
|
#define VP9_ENCODER_VP9_LOOKAHEAD_H_
|
2012-12-19 03:31:19 +04:00
|
|
|
|
2011-04-13 22:00:18 +04:00
|
|
|
#include "vpx_scale/yv12config.h"
|
|
|
|
#include "vpx/vpx_integer.h"
|
|
|
|
|
2014-07-22 21:05:40 +04:00
|
|
|
#if CONFIG_SPATIAL_SVC
|
2014-06-25 01:01:17 +04:00
|
|
|
#include "vpx/vp8cx.h"
|
|
|
|
#include "vpx/vpx_encoder.h"
|
|
|
|
#endif
|
|
|
|
|
2014-01-19 00:16:11 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-07-15 23:26:58 +04:00
|
|
|
#define MAX_LAG_BUFFERS 25
|
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
struct lookahead_entry {
|
|
|
|
YV12_BUFFER_CONFIG img;
|
|
|
|
int64_t ts_start;
|
|
|
|
int64_t ts_end;
|
|
|
|
unsigned int flags;
|
2011-04-13 22:00:18 +04:00
|
|
|
};
|
|
|
|
|
2014-06-25 01:01:17 +04:00
|
|
|
// The max of past frames we want to keep in the queue.
|
|
|
|
#define MAX_PRE_FRAMES 1
|
2011-04-13 22:00:18 +04:00
|
|
|
|
2014-06-25 01:01:17 +04:00
|
|
|
struct lookahead_ctx {
|
|
|
|
unsigned int max_sz; /* Absolute size of the queue */
|
|
|
|
unsigned int sz; /* Number of buffers currently in the queue */
|
|
|
|
unsigned int read_idx; /* Read index */
|
|
|
|
unsigned int write_idx; /* Write index */
|
|
|
|
struct lookahead_entry *buf; /* Buffer list */
|
|
|
|
};
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
/**\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.
|
|
|
|
*/
|
2012-10-30 23:58:42 +04:00
|
|
|
struct lookahead_ctx *vp9_lookahead_init(unsigned int width,
|
2011-04-13 22:00:18 +04:00
|
|
|
unsigned int height,
|
2013-05-07 02:52:06 +04:00
|
|
|
unsigned int subsampling_x,
|
|
|
|
unsigned int subsampling_y,
|
2014-08-26 23:35:15 +04:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
int use_highbitdepth,
|
|
|
|
#endif
|
2013-03-12 04:02:27 +04:00
|
|
|
unsigned int depth);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**\brief Destroys the lookahead stage
|
|
|
|
*/
|
2012-10-30 23:58:42 +04:00
|
|
|
void vp9_lookahead_destroy(struct lookahead_ctx *ctx);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**\brief Enqueue a source buffer
|
|
|
|
*
|
|
|
|
* This function will copy the source image into a new framebuffer with
|
|
|
|
* the expected stride/border.
|
|
|
|
*
|
2011-08-09 23:59:45 +04:00
|
|
|
* 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
|
2011-04-13 22:00:18 +04:00
|
|
|
*/
|
2013-03-12 04:02:27 +04:00
|
|
|
int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
|
2015-01-16 00:56:55 +03:00
|
|
|
int64_t ts_start, int64_t ts_end,
|
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
int use_highbitdepth,
|
|
|
|
#endif
|
|
|
|
unsigned int flags);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**\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
|
|
|
|
*/
|
2013-03-12 04:02:27 +04:00
|
|
|
struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
|
|
|
|
int drain);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**\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
|
|
|
|
*/
|
2013-03-12 04:02:27 +04:00
|
|
|
struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
|
|
|
|
int index);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**\brief Get the number of frames currently in the lookahead queue
|
|
|
|
*
|
|
|
|
* \param[in] ctx Pointer to the lookahead context
|
|
|
|
*/
|
2013-03-12 04:02:27 +04:00
|
|
|
unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
|
2011-04-13 22:00:18 +04:00
|
|
|
|
2014-01-19 00:16:11 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2012-12-19 03:31:19 +04:00
|
|
|
#endif // VP9_ENCODER_VP9_LOOKAHEAD_H_
|