aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-09 11:25:55 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-11 19:14:23 +0200
commitbbff143b07613c3055eaa606b011168e94a3a024 (patch)
tree4d804298c36fe124b82fa50ae2677cf72b4c50ed /libavfilter
parent75b1a555a70c178a9166629e43ec2f6250219eb2 (diff)
downloadffmpeg-bbff143b07613c3055eaa606b011168e94a3a024.tar.gz
lavfi/src_movie: stop using AV_CODEC_FLAG_COPY_OPAQUE
That feature is overkill for a constant pointer to AVFilterLink which can be stored in AVCodecContext.opaque (indirectly, because the link is not allocated yet at the time the codec is opened). This also avoids leaking non-NULL AVFrame.opaque to callers.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/src_movie.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index f0d295d4bb..e50ebc99dc 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -51,6 +51,7 @@
#include "video.h"
typedef struct MovieStream {
+ AVFilterLink *link;
AVStream *st;
AVCodecContext *codec_ctx;
int64_t discontinuity_threshold;
@@ -162,7 +163,8 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
{
int linesize_align[AV_NUM_DATA_POINTERS];
- AVFilterLink *outlink = frame->opaque;
+ MovieStream *st = avctx->opaque;
+ AVFilterLink *outlink = st->link;
int w, h, ow, oh, copy = 0;
AVFrame *new;
@@ -202,7 +204,6 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
av_frame_move_ref(frame, new);
av_frame_free(&new);
- frame->opaque = outlink;
frame->width = ow;
frame->height = oh;
@@ -224,7 +225,7 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
if (!st->codec_ctx)
return AVERROR(ENOMEM);
- st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE;
+ st->codec_ctx->opaque = st;
st->codec_ctx->get_buffer2 = get_buffer;
ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar);
if (ret < 0)
@@ -469,6 +470,8 @@ static int movie_config_output_props(AVFilterLink *outlink)
break;
}
+ st->link = outlink;
+
return 0;
}
@@ -581,7 +584,6 @@ static int activate(AVFilterContext *ctx)
movie->out_index[movie->pkt->stream_index];
if (pkt_out_id >= 0) {
- movie->pkt->opaque = ctx->outputs[pkt_out_id];
ret = decode_packet(ctx, pkt_out_id);
}
av_packet_unref(movie->pkt);