From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id BCABE4F0D7 for ; Sun, 15 Jun 2025 17:04:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0EFFC68DA4C; Sun, 15 Jun 2025 19:59:18 +0300 (EEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id EDF6168DA4E for ; Sun, 15 Jun 2025 19:59:15 +0300 (EEST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3139027b825so2563796a91.0 for ; Sun, 15 Jun 2025 09:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750006754; x=1750611554; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=JcMJg9CA5PRmMEgE8q89anlrOpZkH3KQWQiYmpejzcA=; b=TWD57ieYCv9jyq+9AE1Y2o8kYO/amEku1103AqXZtuSKo6ijd168pbsnfsAsDEfdZw R2Os6aHKK0lWkKmC5IKK+btB9IaQeNDLSsRvmENdogSGDAwH81cqY81lkK5jibZtLwJZ 8BmBd1rYgWOYAyNbvERqnBscqVhOmqDM+pbLrg6YIhVxWIYXSq4ZegB0JxeQL3tk8yq1 EWaWpx+J/hjU+I9foKU7r9uKqZGSoeYdFrOmmfXgBfFo+yW59MWrY1UGGWODKpFxFdpj OY8BOffTgbdGATr9G54gx16xaUStbrlsFHK/fk/8XD63QLSdQ0S60wCGE4+rD+Yv/tZc V9oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750006754; x=1750611554; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=JcMJg9CA5PRmMEgE8q89anlrOpZkH3KQWQiYmpejzcA=; b=qI16xwgUW7wQmSMgwI+CsMWtC9E5kJ+Ad0FRHfp/1Sn/5+ZoKRT6QVKLOyKNehOLNt fYnaO/GbmMWD9ST5b3NU6QVnt1O40M2I8Ml9TQSnwDVj7/NyP5uaDfRpWAUycjMwyGOT akPv+qaeiollzKLZbwjOacv/n72jVgg21/lV6msbRZ5ZG6ALzs4to0yVmcwC6ppmU/kj IqaKDbgVWIPzA04zVn7k2pydgqqd84HXWzz4MTfQuNRoFT7XYzodiuDfmsnUp2M1orju 7LH3Qt9tZaobiPRJB2+J+pl2+rdls7wf+ELqKSKTVsk6cYAPEhUiJtFEgVAhbUX91XTf FFmQ== X-Gm-Message-State: AOJu0YwoIkOn6ZoPX6uM0UmZoO/XePQ8Szk30bfmOwktjTqP8Xp1gLZ6 ER1kK4G/lS1KlZ7F3BxF8nhwVwnhXBcERpCbSpMB2xM5fumHXLm1bZY+SBcqZw== X-Gm-Gg: ASbGncvVvtFX1tYZbdOcXIUxF/1se5jffqekSWm8pxrEeMXeGvoNJyqvnBLFWXdUPmU FdqhDo0Gb8k+rJjy2g6oClydPhzFbVRTsbCfir4ZL4WDRTIQyQc2rOtTO96DJoEgS7L2TbOrevo i8iqsQfFXzXTObwUnfPWJxutqMm6a59jFQAmJyYzMrh7N97ag0Zb9eBJTcp9o3lzXA5SI7iPVeN owBD1mG9SCzD4p756fQeStkJTsikTPBLFtMheQsJmpGZWSMrtdy4YI9Wa3r84mIXmvsI357QE0j sFwKKMTRo6Hk/S23JGHS/uocPRDTJuVowt/Gk8jdcLqXShf3OHcrTfXS6F278VyCEz3GTXCxrRM NcW7awP0QUF/hF3ULltPWLxZzLBg= X-Google-Smtp-Source: AGHT+IFdeufHOmDtKhAkdPDHRXs31ZXaH1YHcEj12032wGIGXfHF6qgy8FM6lHWra/bM8uN0xCnnDw== X-Received: by 2002:a17:90b:5241:b0:311:c5d9:2c79 with SMTP id 98e67ed59e1d1-313f1daa987mr9176749a91.21.1750006754047; Sun, 15 Jun 2025 09:59:14 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-313c1c6a80bsm6863027a91.44.2025.06.15.09.59.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jun 2025 09:59:13 -0700 (PDT) From: Andreas Rheinhardt X-Google-Original-From: Andreas Rheinhardt Message-Id: In-Reply-To: References: Date: Sun, 15 Jun 2025 16:54:38 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 47/47] avcodec/mpeg4videoenc: Fix data race when using AC prediction 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 Cc: Andreas Rheinhardt 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: From: Andreas Rheinhardt The check for whether we can use the fast path to process AC coefficients used the qscale value belonging to a different slice; this worked in practice, because the predicted AC values are zero in this case, so it does not matter whether we use the fast or the slow path. Fix this by checking for first_slice_line instead. This fixes all the races in the encoding part of the vsynth*-mpeg4-thread tests (and fixes them if no frame threading is in use for the decoding part). (The left prediction check may use data from a different slice, too, but said slice is always processed by the same thread, so that no race can happen. Given that out-of-slice AC values are zero, it does not matter whether we use the fast path or the slow path either.) Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg4videoenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 1b8ccad380..a9d673707a 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -205,7 +205,7 @@ static inline int decide_ac_pred(MPVEncContext *const s, int16_t block[6][64], const int xy = s->c.mb_x + s->c.mb_y * s->c.mb_stride - s->c.mb_stride; /* top prediction */ ac_val -= s->c.block_wrap[n] * 16; - if (s->c.mb_y == 0 || s->c.qscale == qscale_table[xy] || n == 2 || n == 3) { + if (s->c.first_slice_line || s->c.qscale == qscale_table[xy] || n == 2 || n == 3) { /* same qscale */ for (i = 1; i < 8; i++) { const int level = block[n][s->c.idsp.idct_permutation[i]]; -- ffmpeg-codebot _______________________________________________ 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".