annotate ffmpeg/libavutil/buffer_internal.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * This file is part of FFmpeg.
yading@11 3 *
yading@11 4 * FFmpeg is free software; you can redistribute it and/or
yading@11 5 * modify it under the terms of the GNU Lesser General Public
yading@11 6 * License as published by the Free Software Foundation; either
yading@11 7 * version 2.1 of the License, or (at your option) any later version.
yading@11 8 *
yading@11 9 * FFmpeg is distributed in the hope that it will be useful,
yading@11 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 12 * Lesser General Public License for more details.
yading@11 13 *
yading@11 14 * You should have received a copy of the GNU Lesser General Public
yading@11 15 * License along with FFmpeg; if not, write to the Free Software
yading@11 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 17 */
yading@11 18
yading@11 19 #ifndef AVUTIL_BUFFER_INTERNAL_H
yading@11 20 #define AVUTIL_BUFFER_INTERNAL_H
yading@11 21
yading@11 22 #include <stdint.h>
yading@11 23
yading@11 24 #include "buffer.h"
yading@11 25
yading@11 26 /**
yading@11 27 * The buffer is always treated as read-only.
yading@11 28 */
yading@11 29 #define BUFFER_FLAG_READONLY (1 << 0)
yading@11 30 /**
yading@11 31 * The buffer was av_realloc()ed, so it is reallocatable.
yading@11 32 */
yading@11 33 #define BUFFER_FLAG_REALLOCATABLE (1 << 1)
yading@11 34
yading@11 35 struct AVBuffer {
yading@11 36 uint8_t *data; /**< data described by this buffer */
yading@11 37 int size; /**< size of data in bytes */
yading@11 38
yading@11 39 /**
yading@11 40 * number of existing AVBufferRef instances referring to this buffer
yading@11 41 */
yading@11 42 volatile int refcount;
yading@11 43
yading@11 44 /**
yading@11 45 * a callback for freeing the data
yading@11 46 */
yading@11 47 void (*free)(void *opaque, uint8_t *data);
yading@11 48
yading@11 49 /**
yading@11 50 * an opaque pointer, to be used by the freeing callback
yading@11 51 */
yading@11 52 void *opaque;
yading@11 53
yading@11 54 /**
yading@11 55 * A combination of BUFFER_FLAG_*
yading@11 56 */
yading@11 57 int flags;
yading@11 58 };
yading@11 59
yading@11 60 typedef struct BufferPoolEntry {
yading@11 61 uint8_t *data;
yading@11 62
yading@11 63 /*
yading@11 64 * Backups of the original opaque/free of the AVBuffer corresponding to
yading@11 65 * data. They will be used to free the buffer when the pool is freed.
yading@11 66 */
yading@11 67 void *opaque;
yading@11 68 void (*free)(void *opaque, uint8_t *data);
yading@11 69
yading@11 70 AVBufferPool *pool;
yading@11 71 struct BufferPoolEntry * volatile next;
yading@11 72 } BufferPoolEntry;
yading@11 73
yading@11 74 struct AVBufferPool {
yading@11 75 BufferPoolEntry * volatile pool;
yading@11 76
yading@11 77 /*
yading@11 78 * This is used to track when the pool is to be freed.
yading@11 79 * The pointer to the pool itself held by the caller is considered to
yading@11 80 * be one reference. Each buffer requested by the caller increases refcount
yading@11 81 * by one, returning the buffer to the pool decreases it by one.
yading@11 82 * refcount reaches zero when the buffer has been uninited AND all the
yading@11 83 * buffers have been released, then it's safe to free the pool and all
yading@11 84 * the buffers in it.
yading@11 85 */
yading@11 86 volatile int refcount;
yading@11 87
yading@11 88 volatile int nb_allocated;
yading@11 89
yading@11 90 int size;
yading@11 91 AVBufferRef* (*alloc)(int size);
yading@11 92 };
yading@11 93
yading@11 94 #endif /* AVUTIL_BUFFER_INTERNAL_H */