mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-28 10:04:37 +08:00
avutil/framepool: provide a single copy for static builds
Both libavfilter and libswscale currently put framepool.o in their regular
OBJS, defining the same four ff_frame_pool_* symbols. Loading both static
archives in full therefore fails with multiple definitions.
Move the implementation and internal header to libavutil. Include the
object in its STLIBOBJS when either consumer is enabled, and use SHLIBOBJS
for the private copies in libavfilter and libswscale. This preserves
independent builds and shared-library symbol visibility without adding
an inter-library dependency or exposing a new public API.
Verified whole-archive links with both consumers, and with each consumer
configured independently. Shared builds pass fate-filter-rgbtestsrc-gbrp12
and fate-filter-rgbtestsrc-gbrap12; static and shared video scaling and
audio volume smoke tests produce identical frame checksums. Also checked
static consumers linked against shared dependencies.
Fixes: 6c89a30ecd
Fixes: #25419
Assisted-by: Fairy
This commit is contained in:
1 parent
ceb466cbcd
commit
a3f1b1e87c
12 files changed
+279
-260
No files matched your search
@@ -17,7 +17,6 @@ OBJS = allfilters.o \
|
||||
ccfifo.o \
|
||||
drawutils.o \
|
||||
formats.o \
|
||||
framepool.o \
|
||||
framequeue.o \
|
||||
graphdump.o \
|
||||
graphparser.o \
|
||||
@@ -672,7 +671,7 @@ OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
|
||||
OBJS-$(CONFIG_MOVIE_FILTER) += src_movie.o
|
||||
|
||||
# Objects duplicated from other libraries for shared builds
|
||||
SHLIBOBJS += log2_tab.o
|
||||
SHLIBOBJS += framepool.o log2_tab.o
|
||||
|
||||
# Windows resource file
|
||||
SHLIBOBJS-$(HAVE_GNU_WINDRES) += avfilterres.o
|
||||
|
||||
+1
-1
@@ -24,12 +24,12 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/eval.h"
|
||||
#include "libavutil/framepool.h"
|
||||
|
||||
#include "audio.h"
|
||||
#include "avfilter.h"
|
||||
#include "avfilter_internal.h"
|
||||
#include "filters.h"
|
||||
#include "framepool.h"
|
||||
|
||||
const AVFilterPad ff_audio_default_filterpad[1] = {
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/eval.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/framepool.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/mem.h"
|
||||
@@ -41,7 +42,6 @@
|
||||
#include "filters.h"
|
||||
#include "formats.h"
|
||||
#include "framequeue.h"
|
||||
#include "framepool.h"
|
||||
#include "video.h"
|
||||
|
||||
static void tlog_ref(void *ctx, AVFrame *ref, int end)
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/framepool.h"
|
||||
|
||||
#include "avfilter.h"
|
||||
#include "filters.h"
|
||||
#include "framepool.h"
|
||||
#include "framequeue.h"
|
||||
|
||||
typedef struct FilterLinkInternal {
|
||||
|
||||
+1
-243
@@ -1,8 +1,6 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* Copyright (c) 2015 Matthieu Bouron <matthieu.bouron stupeflix.com>
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
@@ -18,244 +16,4 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "framepool.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/imgutils_internal.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
|
||||
static av_cold int frame_pool_video_init(int width, int height,
|
||||
enum AVPixelFormat format,
|
||||
int align, FFFramePool *pool)
|
||||
{
|
||||
int ret;
|
||||
|
||||
*pool = (FFFramePool) {
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.pix_fmt = format,
|
||||
.align = align,
|
||||
};
|
||||
|
||||
if ((ret = av_image_check_size2(width, height, INT64_MAX, format, 0, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
ret = av_image_fill_linesizes(pool->linesize, pool->pix_fmt,
|
||||
FFALIGN(pool->width, align));
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
for (int i = 0; i < 4 && pool->linesize[i]; i++)
|
||||
pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
|
||||
|
||||
ptrdiff_t linesizes[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
linesizes[i] = pool->linesize[i];
|
||||
|
||||
size_t sizes[4];
|
||||
ret = av_image_fill_plane_sizes(sizes, pool->pix_fmt,
|
||||
FFALIGN(pool->height, align),
|
||||
linesizes);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
for (int i = 0; i < 4 && sizes[i]; i++) {
|
||||
if (sizes[i] > SIZE_MAX - align)
|
||||
goto fail;
|
||||
pool->pools[i] = av_buffer_pool_init(sizes[i] + align,
|
||||
CONFIG_MEMORY_POISONING
|
||||
? NULL
|
||||
: av_buffer_allocz);
|
||||
if (!pool->pools[i]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_frame_pool_uninit(pool);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static av_cold int frame_pool_audio_init(int channels, int nb_samples,
|
||||
enum AVSampleFormat format,
|
||||
int align, FFFramePool *pool)
|
||||
{
|
||||
int ret;
|
||||
|
||||
int planar = av_sample_fmt_is_planar(format);
|
||||
|
||||
*pool = (FFFramePool) {
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.planes = planar ? channels : 1,
|
||||
.channels = channels,
|
||||
.nb_samples = nb_samples,
|
||||
.sample_fmt = format,
|
||||
.align = align,
|
||||
};
|
||||
|
||||
ret = av_samples_get_buffer_size(&pool->linesize[0], channels,
|
||||
nb_samples, format, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (pool->linesize[0] > SIZE_MAX - align) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pool->pools[0] = av_buffer_pool_init(pool->linesize[0] + align,
|
||||
av_buffer_allocz);
|
||||
if (!pool->pools[0]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_frame_pool_uninit(pool);
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVFrame *ff_frame_pool_get(FFFramePool *pool)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc;
|
||||
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
switch(pool->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
desc = av_pix_fmt_desc_get(pool->pix_fmt);
|
||||
if (!desc)
|
||||
goto fail;
|
||||
|
||||
frame->width = pool->width;
|
||||
frame->height = pool->height;
|
||||
frame->format = pool->pix_fmt;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
frame->linesize[i] = pool->linesize[i];
|
||||
if (!pool->pools[i])
|
||||
break;
|
||||
|
||||
frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
|
||||
if (!frame->buf[i])
|
||||
goto fail;
|
||||
|
||||
frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
|
||||
}
|
||||
|
||||
if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
|
||||
enum AVPixelFormat format = pool->pix_fmt;
|
||||
if (format == AV_PIX_FMT_PAL8)
|
||||
format = AV_PIX_FMT_BGR8;
|
||||
|
||||
av_assert0(frame->data[1] != NULL);
|
||||
if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
frame->extended_data = frame->data;
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
frame->nb_samples = pool->nb_samples;
|
||||
frame->ch_layout.nb_channels = pool->channels;
|
||||
frame->format = pool->sample_fmt;
|
||||
frame->linesize[0] = pool->linesize[0];
|
||||
|
||||
if (pool->planes > AV_NUM_DATA_POINTERS) {
|
||||
frame->extended_data = av_calloc(pool->planes,
|
||||
sizeof(*frame->extended_data));
|
||||
frame->nb_extended_buf = pool->planes - AV_NUM_DATA_POINTERS;
|
||||
frame->extended_buf = av_calloc(frame->nb_extended_buf,
|
||||
sizeof(*frame->extended_buf));
|
||||
if (!frame->extended_data || !frame->extended_buf)
|
||||
goto fail;
|
||||
} else {
|
||||
frame->extended_data = frame->data;
|
||||
av_assert0(frame->nb_extended_buf == 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < FFMIN(pool->planes, AV_NUM_DATA_POINTERS); i++) {
|
||||
frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
|
||||
if (!frame->buf[i])
|
||||
goto fail;
|
||||
frame->extended_data[i] = frame->data[i] =
|
||||
(uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
|
||||
}
|
||||
for (int i = 0; i < frame->nb_extended_buf; i++) {
|
||||
frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
|
||||
if (!frame->extended_buf[i])
|
||||
goto fail;
|
||||
frame->extended_data[i + AV_NUM_DATA_POINTERS] =
|
||||
(uint8_t *)FFALIGN((uintptr_t)frame->extended_buf[i]->data, pool->align);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
av_unreachable("only audio and video frame pools exist");
|
||||
}
|
||||
|
||||
return frame;
|
||||
fail:
|
||||
av_frame_free(&frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
av_cold void ff_frame_pool_uninit(FFFramePool *pool)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
av_buffer_pool_uninit(&pool->pools[i]);
|
||||
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
}
|
||||
|
||||
int ff_frame_pool_video_reinit(FFFramePool *pool,
|
||||
int width,
|
||||
int height,
|
||||
enum AVPixelFormat format,
|
||||
int align)
|
||||
{
|
||||
if (pool->type == AVMEDIA_TYPE_VIDEO &&
|
||||
pool->pix_fmt == format &&
|
||||
FFALIGN(pool->width, pool->align) == FFALIGN(width, align) &&
|
||||
FFALIGN(pool->height, pool->align) == FFALIGN(height, align) &&
|
||||
pool->align == align)
|
||||
{
|
||||
pool->width = width;
|
||||
pool->height = height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ff_frame_pool_uninit(pool);
|
||||
return frame_pool_video_init(width, height, format, align, pool);
|
||||
}
|
||||
|
||||
int ff_frame_pool_audio_reinit(FFFramePool *pool,
|
||||
int channels,
|
||||
int nb_samples,
|
||||
enum AVSampleFormat format,
|
||||
int align)
|
||||
{
|
||||
if (pool->type == AVMEDIA_TYPE_AUDIO &&
|
||||
pool->sample_fmt == format &&
|
||||
pool->channels == channels &&
|
||||
pool->nb_samples == nb_samples &&
|
||||
pool->align == align)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ff_frame_pool_uninit(pool);
|
||||
return frame_pool_audio_init(channels, nb_samples, format, align, pool);
|
||||
}
|
||||
#include "libavutil/framepool.c"
|
||||
+1
-1
@@ -25,13 +25,13 @@
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/framepool.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
|
||||
#include "avfilter.h"
|
||||
#include "avfilter_internal.h"
|
||||
#include "filters.h"
|
||||
#include "framepool.h"
|
||||
#include "video.h"
|
||||
|
||||
const AVFilterPad ff_video_default_filterpad[1] = {
|
||||
|
||||
+2
-1
@@ -228,11 +228,12 @@ OBJS-$(!CONFIG_VULKAN) += hwcontext_stub.o
|
||||
OBJS += $(COMPAT_OBJS:%=../compat/%)
|
||||
|
||||
# Object files to satisfy dependencies of other libraries for static builds
|
||||
STLIBOBJS-$(CONFIG_AVFILTER) += framepool.o
|
||||
STLIBOBJS-$(CONFIG_EXR_DECODER) += half2float.o float2half.o
|
||||
STLIBOBJS-$(CONFIG_EXR_ENCODER) += float2half.o
|
||||
STLIBOBJS-$(CONFIG_PHM_DECODER) += half2float.o
|
||||
STLIBOBJS-$(CONFIG_PHM_ENCODER) += float2half.o
|
||||
STLIBOBJS-$(CONFIG_SWSCALE) += half2float.o
|
||||
STLIBOBJS-$(CONFIG_SWSCALE) += framepool.o half2float.o
|
||||
|
||||
# Windows resource file
|
||||
SHLIBOBJS-$(HAVE_GNU_WINDRES) += avutilres.o
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* Copyright (c) 2015 Matthieu Bouron <matthieu.bouron stupeflix.com>
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "framepool.h"
|
||||
#include "avassert.h"
|
||||
#include "avutil.h"
|
||||
#include "buffer.h"
|
||||
#include "frame.h"
|
||||
#include "imgutils.h"
|
||||
#include "imgutils_internal.h"
|
||||
#include "mem.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
static av_cold int frame_pool_video_init(int width, int height,
|
||||
enum AVPixelFormat format,
|
||||
int align, FFFramePool *pool)
|
||||
{
|
||||
int ret;
|
||||
|
||||
*pool = (FFFramePool) {
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.pix_fmt = format,
|
||||
.align = align,
|
||||
};
|
||||
|
||||
if ((ret = av_image_check_size2(width, height, INT64_MAX, format, 0, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
ret = av_image_fill_linesizes(pool->linesize, pool->pix_fmt,
|
||||
FFALIGN(pool->width, align));
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
for (int i = 0; i < 4 && pool->linesize[i]; i++)
|
||||
pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
|
||||
|
||||
ptrdiff_t linesizes[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
linesizes[i] = pool->linesize[i];
|
||||
|
||||
size_t sizes[4];
|
||||
ret = av_image_fill_plane_sizes(sizes, pool->pix_fmt,
|
||||
FFALIGN(pool->height, align),
|
||||
linesizes);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
for (int i = 0; i < 4 && sizes[i]; i++) {
|
||||
if (sizes[i] > SIZE_MAX - align)
|
||||
goto fail;
|
||||
pool->pools[i] = av_buffer_pool_init(sizes[i] + align,
|
||||
CONFIG_MEMORY_POISONING
|
||||
? NULL
|
||||
: av_buffer_allocz);
|
||||
if (!pool->pools[i]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_frame_pool_uninit(pool);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static av_cold int frame_pool_audio_init(int channels, int nb_samples,
|
||||
enum AVSampleFormat format,
|
||||
int align, FFFramePool *pool)
|
||||
{
|
||||
int ret;
|
||||
|
||||
int planar = av_sample_fmt_is_planar(format);
|
||||
|
||||
*pool = (FFFramePool) {
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.planes = planar ? channels : 1,
|
||||
.channels = channels,
|
||||
.nb_samples = nb_samples,
|
||||
.sample_fmt = format,
|
||||
.align = align,
|
||||
};
|
||||
|
||||
ret = av_samples_get_buffer_size(&pool->linesize[0], channels,
|
||||
nb_samples, format, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (pool->linesize[0] > SIZE_MAX - align) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pool->pools[0] = av_buffer_pool_init(pool->linesize[0] + align,
|
||||
av_buffer_allocz);
|
||||
if (!pool->pools[0]) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_frame_pool_uninit(pool);
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVFrame *ff_frame_pool_get(FFFramePool *pool)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc;
|
||||
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
switch(pool->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
desc = av_pix_fmt_desc_get(pool->pix_fmt);
|
||||
if (!desc)
|
||||
goto fail;
|
||||
|
||||
frame->width = pool->width;
|
||||
frame->height = pool->height;
|
||||
frame->format = pool->pix_fmt;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
frame->linesize[i] = pool->linesize[i];
|
||||
if (!pool->pools[i])
|
||||
break;
|
||||
|
||||
frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
|
||||
if (!frame->buf[i])
|
||||
goto fail;
|
||||
|
||||
frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
|
||||
}
|
||||
|
||||
if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
|
||||
enum AVPixelFormat format = pool->pix_fmt;
|
||||
if (format == AV_PIX_FMT_PAL8)
|
||||
format = AV_PIX_FMT_BGR8;
|
||||
|
||||
av_assert0(frame->data[1] != NULL);
|
||||
if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
frame->extended_data = frame->data;
|
||||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
frame->nb_samples = pool->nb_samples;
|
||||
frame->ch_layout.nb_channels = pool->channels;
|
||||
frame->format = pool->sample_fmt;
|
||||
frame->linesize[0] = pool->linesize[0];
|
||||
|
||||
if (pool->planes > AV_NUM_DATA_POINTERS) {
|
||||
frame->extended_data = av_calloc(pool->planes,
|
||||
sizeof(*frame->extended_data));
|
||||
frame->nb_extended_buf = pool->planes - AV_NUM_DATA_POINTERS;
|
||||
frame->extended_buf = av_calloc(frame->nb_extended_buf,
|
||||
sizeof(*frame->extended_buf));
|
||||
if (!frame->extended_data || !frame->extended_buf)
|
||||
goto fail;
|
||||
} else {
|
||||
frame->extended_data = frame->data;
|
||||
av_assert0(frame->nb_extended_buf == 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < FFMIN(pool->planes, AV_NUM_DATA_POINTERS); i++) {
|
||||
frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
|
||||
if (!frame->buf[i])
|
||||
goto fail;
|
||||
frame->extended_data[i] = frame->data[i] =
|
||||
(uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align);
|
||||
}
|
||||
for (int i = 0; i < frame->nb_extended_buf; i++) {
|
||||
frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
|
||||
if (!frame->extended_buf[i])
|
||||
goto fail;
|
||||
frame->extended_data[i + AV_NUM_DATA_POINTERS] =
|
||||
(uint8_t *)FFALIGN((uintptr_t)frame->extended_buf[i]->data, pool->align);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
av_unreachable("only audio and video frame pools exist");
|
||||
}
|
||||
|
||||
return frame;
|
||||
fail:
|
||||
av_frame_free(&frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
av_cold void ff_frame_pool_uninit(FFFramePool *pool)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
av_buffer_pool_uninit(&pool->pools[i]);
|
||||
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
}
|
||||
|
||||
int ff_frame_pool_video_reinit(FFFramePool *pool,
|
||||
int width,
|
||||
int height,
|
||||
enum AVPixelFormat format,
|
||||
int align)
|
||||
{
|
||||
if (pool->type == AVMEDIA_TYPE_VIDEO &&
|
||||
pool->pix_fmt == format &&
|
||||
FFALIGN(pool->width, pool->align) == FFALIGN(width, align) &&
|
||||
FFALIGN(pool->height, pool->align) == FFALIGN(height, align) &&
|
||||
pool->align == align)
|
||||
{
|
||||
pool->width = width;
|
||||
pool->height = height;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ff_frame_pool_uninit(pool);
|
||||
return frame_pool_video_init(width, height, format, align, pool);
|
||||
}
|
||||
|
||||
int ff_frame_pool_audio_reinit(FFFramePool *pool,
|
||||
int channels,
|
||||
int nb_samples,
|
||||
enum AVSampleFormat format,
|
||||
int align)
|
||||
{
|
||||
if (pool->type == AVMEDIA_TYPE_AUDIO &&
|
||||
pool->sample_fmt == format &&
|
||||
pool->channels == channels &&
|
||||
pool->nb_samples == nb_samples &&
|
||||
pool->align == align)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ff_frame_pool_uninit(pool);
|
||||
return frame_pool_audio_init(channels, nb_samples, format, align, pool);
|
||||
}
|
||||
@@ -18,12 +18,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_FRAMEPOOL_H
|
||||
#define AVFILTER_FRAMEPOOL_H
|
||||
#ifndef AVUTIL_FRAMEPOOL_H
|
||||
#define AVUTIL_FRAMEPOOL_H
|
||||
|
||||
#include "libavutil/buffer.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "buffer.h"
|
||||
#include "frame.h"
|
||||
#include "internal.h"
|
||||
|
||||
/**
|
||||
* Frame pool. This structure must be initialized with
|
||||
@@ -106,4 +106,4 @@ void ff_frame_pool_uninit(FFFramePool *pool);
|
||||
AVFrame *ff_frame_pool_get(FFFramePool *pool);
|
||||
|
||||
|
||||
#endif /* AVFILTER_FRAMEPOOL_H */
|
||||
#endif /* AVUTIL_FRAMEPOOL_H */
|
||||
+1
-2
@@ -12,7 +12,6 @@ OBJS = alphablend.o \
|
||||
hscale_fast_bilinear.o \
|
||||
filters.o \
|
||||
format.o \
|
||||
framepool.o \
|
||||
gamma.o \
|
||||
graph.o \
|
||||
input.o \
|
||||
@@ -44,7 +43,7 @@ include $(SRC_PATH)/libswscale/vulkan/Makefile
|
||||
endif
|
||||
|
||||
# Objects duplicated from other libraries for shared builds
|
||||
SHLIBOBJS += log2_tab.o half2float.o
|
||||
SHLIBOBJS += framepool.o log2_tab.o half2float.o
|
||||
|
||||
# Windows resource file
|
||||
SHLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavfilter/framepool.c"
|
||||
#include "libavutil/framepool.c"
|
||||
@@ -28,10 +28,10 @@
|
||||
#include "swscale.h"
|
||||
#include "graph.h"
|
||||
|
||||
#include "libavfilter/framepool.h"
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/framepool.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
|
||||
Reference in new issue
Block a user