From patchwork Sun Dec 4 21:52:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 39591 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2818400pzb; Sun, 4 Dec 2022 13:53:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Zi+iU4jxOEOcsnocClYcGB/Jfus7J1rKi7oI3JSJE6QKba7pCRGbvptY8vlsBLz6PbYvc X-Received: by 2002:a05:6402:1107:b0:463:9b53:cbf6 with SMTP id u7-20020a056402110700b004639b53cbf6mr64396952edv.173.1670190819954; Sun, 04 Dec 2022 13:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670190819; cv=none; d=google.com; s=arc-20160816; b=pEIIjWKESKMMDd1sKfemXm08pQsOjMR6xTGAIdi6L2fmMQL7FikXmXPoe0ugYPV/yw CBjN2benK33JW/g+3paFzl/v2UaqZq+Gm3qOJ1ELXOJvlBbk0HpX9KS5IAff32Vhb0VD nbHu8L3dJ2SaaQHKq29F1wVtpC+GsjDb1+FyqDZkBGZkziooQW+Xuhm1N4+kfMhKiwRf CZQbvSIwDvZ+s80gSBhuvpayYhayWvebD6+NCnwMME71KWbOsS2WpBZDPqegHc4ftQBk rdYMM34n+VZjDuEcnrkhKl23SkYs4ablD7U5ySUlU5lmLA3I5FqMqy21jo/mGD/EZBMW oWCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=8yLF2bNOY4Q1A1wzbcE8soHUF8JjGDrhudtNSePSInk=; b=rpjG0h4lZz11f/KuHgLB+vdkGuohIWjnDkU7UcSyYVFxymCEqfOr7KWmaFiOvw/JZg maJWhnmlwBtfMfqgF5Lsc2d6K/bC8B4ZCGkv83xUA8Tiz/1wqXkuxRCTPcFKCC4AP6D3 tSSfiitjlKTCwNUS+0LdqvNKJGAOm2XgbWWCt6PnyI0rPsNX22aorfgRsfpPiKC0emNp ahziGkk5Z0Bb2f5KqZPMO3bwY9w8Yq+98du6yn27+mZpnu9NZgUVgiDEbB+gDwr+rnAu s7MBVrwLTtQaNXzcJ2s+aQP7sPBd3iJJR8Da72y0CPDgQ9qy2ZobyoQ0/3QKTs3S3qMe fVBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=q0wvh74O; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e18-20020a17090658d200b007c0b44ec243si8942031ejs.781.2022.12.04.13.53.39; Sun, 04 Dec 2022 13:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=q0wvh74O; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3310568BBF1; Sun, 4 Dec 2022 23:53:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: f/VspvTZDID7 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;