lookahead.h 3.1 KB

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