summaryrefslogtreecommitdiff
path: root/cmdutils.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-05-30 07:57:59 +0200
committerAnton Khirnov <anton@khirnov.net>2012-06-05 09:35:58 +0200
commitd55c2e05b5d07154ce374e159bbc1a6cf40e57d3 (patch)
treeacbd9357cbb5bb3e1854d0e26702515fba894bc2 /cmdutils.h
parent3ffa233595fbf1b85841a55c8886e6942f8648d8 (diff)
downloadffmpeg-d55c2e05b5d07154ce374e159bbc1a6cf40e57d3.tar.gz
avtools: move buffer management code from avconv to cmdutils.
It will be used by avplay.
Diffstat (limited to 'cmdutils.h')
-rw-r--r--cmdutils.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmdutils.h b/cmdutils.h
index 6fff47ddeb..5dac13037a 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -383,4 +383,46 @@ void exit_program(int ret);
*/
void *grow_array(void *array, int elem_size, int *size, int new_size);
+typedef struct FrameBuffer {
+ uint8_t *base[4];
+ uint8_t *data[4];
+ int linesize[4];
+
+ int h, w;
+ enum PixelFormat pix_fmt;
+
+ int refcount;
+ struct FrameBuffer **pool; ///< head of the buffer pool
+ struct FrameBuffer *next;
+} FrameBuffer;
+
+/**
+ * Get a frame from the pool. This is intended to be used as a callback for
+ * AVCodecContext.get_buffer.
+ *
+ * @param s codec context. s->opaque must be a pointer to the head of the
+ * buffer pool.
+ * @param frame frame->opaque will be set to point to the FrameBuffer
+ * containing the frame data.
+ */
+int codec_get_buffer(AVCodecContext *s, AVFrame *frame);
+
+/**
+ * A callback to be used for AVCodecContext.release_buffer along with
+ * codec_get_buffer().
+ */
+void codec_release_buffer(AVCodecContext *s, AVFrame *frame);
+
+/**
+ * A callback to be used for AVFilterBuffer.free.
+ * @param fb buffer to free. fb->priv must be a pointer to the FrameBuffer
+ * containing the buffer data.
+ */
+void filter_release_buffer(AVFilterBuffer *fb);
+
+/**
+ * Free all the buffers in the pool. This must be called after all the
+ * buffers have been released.
+ */
+void free_buffer_pool(FrameBuffer **pool);
#endif /* LIBAV_CMDUTILS_H */