/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718#ifndef AVUTIL_BUFFER_INTERNAL_H19#define AVUTIL_BUFFER_INTERNAL_H2021#include <stdint.h>2223#include "buffer.h"24#include "thread.h"2526/**27* The buffer is always treated as read-only.28*/29#define BUFFER_FLAG_READONLY (1 << 0)30/**31* The buffer was av_realloc()ed, so it is reallocatable.32*/33#define BUFFER_FLAG_REALLOCATABLE (1 << 1)3435struct AVBuffer {36uint8_t *data; /**< data described by this buffer */37int size; /**< size of data in bytes */3839/**40* number of existing AVBufferRef instances referring to this buffer41*/42volatile int refcount;4344/**45* a callback for freeing the data46*/47void (*free)(void *opaque, uint8_t *data);4849/**50* an opaque pointer, to be used by the freeing callback51*/52void *opaque;5354/**55* A combination of BUFFER_FLAG_*56*/57int flags;58};5960typedef struct BufferPoolEntry {61uint8_t *data;6263/*64* Backups of the original opaque/free of the AVBuffer corresponding to65* data. They will be used to free the buffer when the pool is freed.66*/67void *opaque;68void (*free)(void *opaque, uint8_t *data);6970AVBufferPool *pool;71struct BufferPoolEntry *next;72} BufferPoolEntry;7374struct AVBufferPool {75AVMutex mutex;76BufferPoolEntry *pool;7778/*79* This is used to track when the pool is to be freed.80* The pointer to the pool itself held by the caller is considered to81* be one reference. Each buffer requested by the caller increases refcount82* by one, returning the buffer to the pool decreases it by one.83* refcount reaches zero when the buffer has been uninited AND all the84* buffers have been released, then it's safe to free the pool and all85* the buffers in it.86*/87volatile int refcount;8889volatile int nb_allocated;9091int size;92AVBufferRef* (*alloc)(int size);93};9495#endif /* AVUTIL_BUFFER_INTERNAL_H */969798