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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/src_movie.c+6−4
@@ -51,6 +51,7 @@ · 50 unmodified lines
51#include "video.h"51#include "video.h"
52 52
53typedef struct MovieStream {53typedef struct MovieStream {
54 AVFilterLink *link;
54 AVStream *st;55 AVStream *st;
55 AVCodecContext *codec_ctx;56 AVCodecContext *codec_ctx;
56 int64_t discontinuity_threshold;57 int64_t discontinuity_threshold;
@@ -162,7 +163,8 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) · 105 unmodified lines
162static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)163static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
163{164{
164 int linesize_align[AV_NUM_DATA_POINTERS];165 int linesize_align[AV_NUM_DATA_POINTERS];
165 AVFilterLink *outlink = frame->opaque;166 MovieStream *st = avctx->opaque;
167 AVFilterLink *outlink = st->link;
166 int w, h, ow, oh, copy = 0;168 int w, h, ow, oh, copy = 0;
167 AVFrame *new;169 AVFrame *new;
168 170
@@ -202,7 +204,6 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) · 33 unmodified lines
202 av_frame_move_ref(frame, new);204 av_frame_move_ref(frame, new);
203 av_frame_free(&new);205 av_frame_free(&new);
204 206
205 frame->opaque = outlink;
206 frame->width = ow;207 frame->width = ow;
207 frame->height = oh;208 frame->height = oh;
208 209
@@ -224,7 +225,7 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) · 15 unmodified lines
224 if (!st->codec_ctx)225 if (!st->codec_ctx)
225 return AVERROR(ENOMEM);226 return AVERROR(ENOMEM);
226 227
227 st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE;228 st->codec_ctx->opaque = st;
228 st->codec_ctx->get_buffer2 = get_buffer;229 st->codec_ctx->get_buffer2 = get_buffer;
229 ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar);230 ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar);
230 if (ret < 0)231 if (ret < 0)
@@ -469,6 +470,8 @@ static int movie_config_output_props(AVFilterLink *outlink) · 238 unmodified lines
469 break;470 break;
470 }471 }
471 472
473 st->link = outlink;
474
472 return 0;475 return 0;
473}476}
474 477
@@ -581,7 +584,6 @@ static int activate(AVFilterContext *ctx) · 106 unmodified lines
581 movie->out_index[movie->pkt->stream_index];584 movie->out_index[movie->pkt->stream_index];
582 585
583 if (pkt_out_id >= 0) {586 if (pkt_out_id >= 0) {
584 movie->pkt->opaque = ctx->outputs[pkt_out_id];
585 ret = decode_packet(ctx, pkt_out_id);587 ret = decode_packet(ctx, pkt_out_id);
586 }588 }
587 av_packet_unref(movie->pkt);589 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