You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.5KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * Copyright (c) 2015 Matthieu Bouron <matthieu.bouron stupeflix.com>
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVFILTER_FRAMEPOOL_H
  21. #define AVFILTER_FRAMEPOOL_H
  22. #include "libavutil/buffer.h"
  23. #include "libavutil/frame.h"
  24. #include "libavutil/internal.h"
  25. /**
  26. * Frame pool. This structure is opaque and not meant to be accessed
  27. * directly. It is allocated with ff_frame_pool_init() and freed with
  28. * ff_frame_pool_uninit().
  29. */
  30. typedef struct FFFramePool FFFramePool;
  31. /**
  32. * Allocate and initialize a video frame pool.
  33. *
  34. * @param alloc a function that will be used to allocate new frame buffers when
  35. * the pool is empty. May be NULL, then the default allocator will be used
  36. * (av_buffer_alloc()).
  37. * @param width width of each frame in this pool
  38. * @param height height of each frame in this pool
  39. * @param format format of each frame in this pool
  40. * @param align buffers alignement of each frame in this pool
  41. * @return newly created video frame pool on success, NULL on error.
  42. */
  43. FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(buffer_size_t size),
  44. int width,
  45. int height,
  46. enum AVPixelFormat format,
  47. int align);
  48. /**
  49. * Allocate and initialize an audio frame pool.
  50. *
  51. * @param alloc a function that will be used to allocate new frame buffers when
  52. * the pool is empty. May be NULL, then the default allocator will be used
  53. * (av_buffer_alloc()).
  54. * @param channels channels of each frame in this pool
  55. * @param nb_samples number of samples of each frame in this pool
  56. * @param format format of each frame in this pool
  57. * @param align buffers alignement of each frame in this pool
  58. * @return newly created audio frame pool on success, NULL on error.
  59. */
  60. FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(buffer_size_t size),
  61. int channels,
  62. int samples,
  63. enum AVSampleFormat format,
  64. int align);
  65. /**
  66. * Deallocate the frame pool. It is safe to call this function while
  67. * some of the allocated frame are still in use.
  68. *
  69. * @param pool pointer to the frame pool to be freed. It will be set to NULL.
  70. */
  71. void ff_frame_pool_uninit(FFFramePool **pool);
  72. /**
  73. * Get the video frame pool configuration.
  74. *
  75. * @param width width of each frame in this pool
  76. * @param height height of each frame in this pool
  77. * @param format format of each frame in this pool
  78. * @param align buffers alignement of each frame in this pool
  79. * @return 0 on success, a negative AVERROR otherwise.
  80. */
  81. int ff_frame_pool_get_video_config(FFFramePool *pool,
  82. int *width,
  83. int *height,
  84. enum AVPixelFormat *format,
  85. int *align);
  86. /**
  87. * Get the audio frame pool configuration.
  88. *
  89. * @param channels channels of each frame in this pool
  90. * @param nb_samples number of samples of each frame in this pool
  91. * @param format format of each frame in this pool
  92. * @param align buffers alignement of each frame in this pool
  93. * @return 0 on success, a negative AVERROR otherwise.
  94. */
  95. int ff_frame_pool_get_audio_config(FFFramePool *pool,
  96. int *channels,
  97. int *nb_samples,
  98. enum AVSampleFormat *format,
  99. int *align);
  100. /**
  101. * Allocate a new AVFrame, reussing old buffers from the pool when available.
  102. * This function may be called simultaneously from multiple threads.
  103. *
  104. * @return a new AVFrame on success, NULL on error.
  105. */
  106. AVFrame *ff_frame_pool_get(FFFramePool *pool);
  107. #endif /* AVFILTER_FRAMEPOOL_H */