History

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.

Anton Khirnov committed 3 years ago

Commit bbff1431 parent 75b1a551 file · +6 −4Browse files

Unified · Split

libavfilter/src_movie.c+6−4
@@ -51,6 +51,7 @@ · 50 unmodified lines
5151 #include "video.h"
5252
5353 typedef struct MovieStream {
54+ AVFilterLink *link;
5455 AVStream *st;
5556 AVCodecContext *codec_ctx;
5657 int64_t discontinuity_threshold;
@@ -162,7 +163,8 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) · 105 unmodified lines
162163 static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
163164 {
164165 int linesize_align[AV_NUM_DATA_POINTERS];
165− AVFilterLink *outlink = frame->opaque;
166+ MovieStream *st = avctx->opaque;
167+ AVFilterLink *outlink = st->link;
166168 int w, h, ow, oh, copy = 0;
167169 AVFrame *new;
168170
@@ -202,7 +204,6 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 33 unmodified lines
202204 av_frame_move_ref(frame, new);
203205 av_frame_free(&new);
204206
205− frame->opaque = outlink;
206207 frame->width = ow;
207208 frame->height = oh;
208209
@@ -224,7 +225,7 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) · 15 unmodified lines
224225 if (!st->codec_ctx)
225226 return AVERROR(ENOMEM);
226227
227− st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE;
228+ st->codec_ctx->opaque = st;
228229 st->codec_ctx->get_buffer2 = get_buffer;
229230 ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar);
230231 if (ret < 0)
@@ -469,6 +470,8 @@ static int movie_config_output_props(AVFilterLink *outlink) · 238 unmodified lines
469470 break;
470471 }
471472
473+ st->link = outlink;
474+
472475 return 0;
473476 }
474477
@@ -581,7 +584,6 @@ static int activate(AVFilterContext *ctx) · 106 unmodified lines
581584 movie->out_index[movie->pkt->stream_index];
582585
583586 if (pkt_out_id >= 0) {
584− movie->pkt->opaque = ctx->outputs[pkt_out_id];
585587 ret = decode_packet(ctx, pkt_out_id);
586588 }
587589 av_packet_unref(movie->pkt);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t