mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avfilter/buffersrc: simplify av_buffersrc_add_frame_flags()
Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
38aea9b041
commit
04dfdde09b
@ -149,33 +149,6 @@ int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *fr
|
|||||||
return av_buffersrc_add_frame_flags(ctx, frame, 0);
|
return av_buffersrc_add_frame_flags(ctx, frame, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
|
|
||||||
AVFrame *frame, int flags);
|
|
||||||
|
|
||||||
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
|
|
||||||
{
|
|
||||||
AVFrame *copy = NULL;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (frame && frame->channel_layout &&
|
|
||||||
av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
|
|
||||||
av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & AV_BUFFERSRC_FLAG_KEEP_REF) || !frame)
|
|
||||||
return av_buffersrc_add_frame_internal(ctx, frame, flags);
|
|
||||||
|
|
||||||
if (!(copy = av_frame_alloc()))
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
ret = av_frame_ref(copy, frame);
|
|
||||||
if (ret >= 0)
|
|
||||||
ret = av_buffersrc_add_frame_internal(ctx, copy, flags);
|
|
||||||
|
|
||||||
av_frame_free(©);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int push_frame(AVFilterGraph *graph)
|
static int push_frame(AVFilterGraph *graph)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -190,13 +163,18 @@ static int push_frame(AVFilterGraph *graph)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
|
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
|
||||||
AVFrame *frame, int flags)
|
|
||||||
{
|
{
|
||||||
BufferSourceContext *s = ctx->priv;
|
BufferSourceContext *s = ctx->priv;
|
||||||
AVFrame *copy;
|
AVFrame *copy;
|
||||||
int refcounted, ret;
|
int refcounted, ret;
|
||||||
|
|
||||||
|
if (frame && frame->channel_layout &&
|
||||||
|
av_get_channel_layout_nb_channels(frame->channel_layout) != frame->channels) {
|
||||||
|
av_log(ctx, AV_LOG_ERROR, "Layout indicates a different number of channels than actually present\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
s->nb_failed_requests = 0;
|
s->nb_failed_requests = 0;
|
||||||
|
|
||||||
if (!frame)
|
if (!frame)
|
||||||
@ -229,7 +207,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
|
|||||||
if (!(copy = av_frame_alloc()))
|
if (!(copy = av_frame_alloc()))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (refcounted) {
|
if (refcounted && !(flags & AV_BUFFERSRC_FLAG_KEEP_REF)) {
|
||||||
av_frame_move_ref(copy, frame);
|
av_frame_move_ref(copy, frame);
|
||||||
} else {
|
} else {
|
||||||
ret = av_frame_ref(copy, frame);
|
ret = av_frame_ref(copy, frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user