From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avfilter/src_movie: stop using AVPacket on stack Date: Fri, 19 May 2023 23:40:05 -0300 Message-ID: <20230520024005.4743-1-jamrial@gmail.com> (raw) Signed-off-by: James Almer <jamrial@gmail.com> --- libavfilter/src_movie.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 5937613d13..b55c2bcb6e 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -72,6 +72,7 @@ typedef struct MovieContext { int dec_threads; AVFormatContext *format_ctx; + AVPacket *pkt; int max_stream_index; /**< max stream # actually used for output */ MovieStream *st; /**< array of all streams, one per output */ @@ -279,6 +280,10 @@ static av_cold int movie_common_init(AVFilterContext *ctx) for (i = 0; i < movie->format_ctx->nb_streams; i++) movie->format_ctx->streams[i]->discard = AVDISCARD_ALL; + movie->pkt = av_packet_alloc(); + if (!movie->pkt) + return AVERROR(ENOMEM); + movie->st = av_calloc(nb_streams, sizeof(*movie->st)); if (!movie->st) return AVERROR(ENOMEM); @@ -348,6 +353,7 @@ static av_cold void movie_uninit(AVFilterContext *ctx) av_freep(&movie->out_index); if (movie->format_ctx) avformat_close_input(&movie->format_ctx); + av_packet_free(&movie->pkt); } static int movie_query_formats(AVFilterContext *ctx) @@ -459,11 +465,11 @@ static int rewind_file(AVFilterContext *ctx) static int movie_decode_packet(AVFilterContext *ctx) { MovieContext *movie = ctx->priv; - AVPacket pkt = { 0 }; + AVPacket *pkt = movie->pkt; int pkt_out_id, ret; /* read a new packet from input stream */ - ret = av_read_frame(movie->format_ctx, &pkt); + ret = av_read_frame(movie->format_ctx, pkt); if (ret == AVERROR_EOF) { /* EOF -> set all decoders for flushing */ for (int i = 0; i < ctx->nb_outputs; i++) { @@ -477,11 +483,11 @@ static int movie_decode_packet(AVFilterContext *ctx) return ret; /* send the packet to its decoder, if any */ - pkt_out_id = pkt.stream_index > movie->max_stream_index ? -1 : - movie->out_index[pkt.stream_index]; + pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 : + movie->out_index[pkt->stream_index]; if (pkt_out_id >= 0) - ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt); - av_packet_unref(&pkt); + ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, pkt); + av_packet_unref(pkt); return ret; } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-05-20 2:40 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-20 2:40 James Almer [this message] 2023-05-20 9:41 ` Paul B Mahol 2023-05-20 11:18 ` James Almer 2023-05-20 11:43 ` Paul B Mahol 2023-05-20 12:00 ` James Almer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230520024005.4743-1-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git