Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / vp9 / encoder / vp9_lookahead.h
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
11 #ifndef VP9_ENCODER_VP9_LOOKAHEAD_H_
12 #define VP9_ENCODER_VP9_LOOKAHEAD_H_
13
14 #include "vpx_scale/yv12config.h"
15 #include "vpx/vpx_integer.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 #define MAX_LAG_BUFFERS 25
22
23 struct lookahead_entry {
24   YV12_BUFFER_CONFIG  img;
25   int64_t             ts_start;
26   int64_t             ts_end;
27   unsigned int        flags;
28 };
29
30
31 struct lookahead_ctx;
32
33 /**\brief Initializes the lookahead stage
34  *
35  * The lookahead stage is a queue of frame buffers on which some analysis
36  * may be done when buffers are enqueued.
37  */
38 struct lookahead_ctx *vp9_lookahead_init(unsigned int width,
39                                          unsigned int height,
40                                          unsigned int subsampling_x,
41                                          unsigned int subsampling_y,
42                                          unsigned int depth);
43
44
45 /**\brief Destroys the lookahead stage
46  */
47 void vp9_lookahead_destroy(struct lookahead_ctx *ctx);
48
49
50 /**\brief Enqueue a source buffer
51  *
52  * This function will copy the source image into a new framebuffer with
53  * the expected stride/border.
54  *
55  * If active_map is non-NULL and there is only one frame in the queue, then copy
56  * only active macroblocks.
57  *
58  * \param[in] ctx         Pointer to the lookahead context
59  * \param[in] src         Pointer to the image to enqueue
60  * \param[in] ts_start    Timestamp for the start of this frame
61  * \param[in] ts_end      Timestamp for the end of this frame
62  * \param[in] flags       Flags set on this frame
63  * \param[in] active_map  Map that specifies which macroblock is active
64  */
65 int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
66                        int64_t ts_start, int64_t ts_end, unsigned int flags,
67                        unsigned char *active_map);
68
69
70 /**\brief Get the next source buffer to encode
71  *
72  *
73  * \param[in] ctx       Pointer to the lookahead context
74  * \param[in] drain     Flag indicating the buffer should be drained
75  *                      (return a buffer regardless of the current queue depth)
76  *
77  * \retval NULL, if drain set and queue is empty
78  * \retval NULL, if drain not set and queue not of the configured depth
79  */
80 struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
81                                           int drain);
82
83
84 /**\brief Get a future source buffer to encode
85  *
86  * \param[in] ctx       Pointer to the lookahead context
87  * \param[in] index     Index of the frame to be returned, 0 == next frame
88  *
89  * \retval NULL, if no buffer exists at the specified index
90  */
91 struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
92                                            int index);
93
94
95 /**\brief Get the number of frames currently in the lookahead queue
96  *
97  * \param[in] ctx       Pointer to the lookahead context
98  */
99 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
100
101 #ifdef __cplusplus
102 }  // extern "C"
103 #endif
104
105 #endif  // VP9_ENCODER_VP9_LOOKAHEAD_H_