From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/pthread_frame.c: keep the last_pkt_props from worker threads in sync with the user context Date: Sun, 4 Dec 2022 18:52:26 -0300 Message-ID: <20221204215227.4186-4-jamrial@gmail.com> (raw) In-Reply-To: <20221204215227.4186-1-jamrial@gmail.com> Making it point to the input packet results in different behavior during flush, where its contents will be that of an empty packet instead of containing the props from the last input packet fed to the decoder. After this change, decoding with more than one thread will shield the same results as using a single thread. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/pthread_frame.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index df82a4125f..3397e0cc66 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -371,6 +371,8 @@ FF_ENABLE_DEPRECATION_WARNINGS */ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src) { + int err; + dst->flags = src->flags; dst->draw_horiz_band= src->draw_horiz_band; @@ -406,6 +408,12 @@ FF_ENABLE_DEPRECATION_WARNINGS src->slice_count * sizeof(*dst->slice_offset)); } dst->slice_count = src->slice_count; + + av_packet_unref(dst->internal->last_pkt_props); + err = av_packet_copy_props(dst->internal->last_pkt_props, src->internal->last_pkt_props); + if (err < 0) + return err; + return 0; } @@ -775,6 +783,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&ctx->slice_offset); av_buffer_unref(&ctx->internal->pool); + av_packet_free(&ctx->internal->last_pkt_props); av_freep(&ctx->internal); av_buffer_unref(&ctx->hw_frames_ctx); } @@ -846,9 +855,9 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, return err; if (!(p->frame = av_frame_alloc()) || - !(p->avpkt = av_packet_alloc())) + !(p->avpkt = av_packet_alloc()) || + !(copy->internal->last_pkt_props = av_packet_alloc())) return AVERROR(ENOMEM); - copy->internal->last_pkt_props = p->avpkt; if (!first) copy->internal->is_copy = 1; -- 2.38.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 prev parent reply other threads:[~2022-12-04 21:53 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-04 21:52 [FFmpeg-devel] [PATCH 1/5] avcodec/binkaudio: clear pts when returning more than one frame per input packet James Almer 2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 2/5] Revert "avcodec/decode: use a packet list to store packet properties" James Almer 2022-12-05 21:26 ` Michael Niedermayer 2022-12-06 0:03 ` [FFmpeg-devel] [PATCH 2/6] avcodec/wmadec: clear pts when returning a frame during flush James Almer 2022-12-06 8:27 ` Paul B Mahol 2022-12-06 11:42 ` James Almer 2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 3/5] avcodec/decode: don't set last_pkt_props->size James Almer 2022-12-04 21:52 ` James Almer [this message] 2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 5/5] avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded frame was skipped James Almer 2022-12-06 9:17 ` Andreas Rheinhardt 2022-12-06 11:21 ` James Almer 2022-12-12 11:37 ` 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=20221204215227.4186-4-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