From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 763DC40192 for ; Sun, 4 Dec 2022 21:53:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03CD468BBF2; Sun, 4 Dec 2022 23:53:16 +0200 (EET) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55AD668BBE6 for ; Sun, 4 Dec 2022 23:53:09 +0200 (EET) Received: by mail-oi1-f177.google.com with SMTP id n186so11042554oih.7 for ; Sun, 04 Dec 2022 13:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4Vdejytl3fJlr1UFL0Ym6hZ9nkrFyzQIJSpJDIwNQao=; b=q0wvh74OhQUhEw3Q77LruSWqA8DLQcAWjpXU9PBU9wALqrY655iIIRw84Z8WUeD2Zc 4Hfwl45RldkznosvZWB1q9TsL88/PnAo/Got2Is1le2O/rrqLdajsDvQ+ErG4LIbHAXF bdoL/oscOAS4/ULl4pEQ+d92/RETke7tBCuyfX9aoSJYFNqJgG6DM/jw4KWq16P+d/iT T5xXhhq7loFWMN5E2jUuo5Sl52An4qmgkA7AReE0IDUhxNo673xbsD2X+GM7vfVpK7tD tkfl11SSJfBmEZ0kwusdWuDa3Uz+4oeA8YA4/FDwTwFw+GDA2k4jVSeNwxS2AD/PCJbl s7sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Vdejytl3fJlr1UFL0Ym6hZ9nkrFyzQIJSpJDIwNQao=; b=Al0oliBgGavOr+z7VpYyH9Z+9oqp5Y+liJm5tjzEcRC0a9xkTzY0PPU5HBKrHy9kNG GKflZoZJq2w3WBKzkO8J+w3XWygDw0jhfXzeliFJrwN4QhFZdiceQAaOeaNYQVup1eop gyuakDx1o8Rpw9rpz/zdllZbvpoaYf8NF1X70zaIc+6Ofl9jtx3fHF5nqDuykitJB+g0 Xe0jb8oYIQnp3xVr8YtOWs92pJJFYJZsoPdlEBdJKUN/BtlxsKmdZcVfV2QukGsOX1bO N3H39IL+FAeM0LdTW8fq886JS7ozapaZVboUKHoqtUCH9P97745rx6LzpC60xAKpuGpH dUwg== X-Gm-Message-State: ANoB5pmCFZ2gNt8C65RIFZ4ucFe3C87aG8sCWLe7grZolNnR/Isv5Fb4 T9tfTG1sg5Td8LsfEha4EQBSlRZEsD4= X-Google-Smtp-Source: AA0mqf7C9w+jvUOw3OEAiZx7tDMdtt8ewjku6OOjwt5EPecmqaFps6YVI7HrAUM5neQg3pNL2M6fZg== X-Received: by 2002:a05:6808:2028:b0:35b:e648:5280 with SMTP id q40-20020a056808202800b0035be6485280mr7726833oiw.254.1670190787785; Sun, 04 Dec 2022 13:53:07 -0800 (PST) Received: from localhost.localdomain ([181.85.72.69]) by smtp.gmail.com with ESMTPSA id s16-20020a056830439000b0066c7733be43sm6823100otv.30.2022.12.04.13.53.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Dec 2022 13:53:07 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Dec 2022 18:52:26 -0300 Message-Id: <20221204215227.4186-4-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204215227.4186-1-jamrial@gmail.com> References: <20221204215227.4186-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/pthread_frame.c: keep the last_pkt_props from worker threads in sync with the user context X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 --- 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".