From patchwork Sun Mar 22 15:55:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 18355 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 81D2344A7AA for ; Sun, 22 Mar 2020 18:18:22 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5FADC68B4E3; Sun, 22 Mar 2020 18:18:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C2A468B0E6 for ; Sun, 22 Mar 2020 18:18:16 +0200 (EET) Received: by mail-qt1-f194.google.com with SMTP id i3so5734169qtv.8 for ; Sun, 22 Mar 2020 09:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=YgHP9bBXJZShDaL7aOvh2TA2drwYpBwU8fA82XoIezE=; b=OkUrAiz8RHajeVhuJaaRIeCLNTxSMhrsKUts0gL7UwQr+OOYbx3rzvuI11hjs99QLj QdCLr3qVaSw7pFUsXYjINIH+/AlGbJXPdyKe0qNMBRFfQkmsm83nlp4Sr3G/QV14bN/r ixyyRV3ZCiSUlpGAGtLWsxCSzcoFbnZj0tMM+u+OXsd9yOfE9cKfk3oskIGzgFZtovP5 ruAFij5jAW8gbS4OQNx96eHo0SmudmCHdgJ3asgyFZswXVekXN/ffMYANbKYL0UN13Ce /Sbp3sQdJnM50ZRPYE/MnikhPG5IDmuFiZSiALpUz0WxeMjeJXkpsw9kFWF1hng+qAU2 gSag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YgHP9bBXJZShDaL7aOvh2TA2drwYpBwU8fA82XoIezE=; b=hu0iFh3udBhomz1nYDauSQx2yCeQk15HEgx71BhWCMYdxnW29cBMw7XezyibBJ6jxJ thdnOEf8DR8cupHvc0Ztb71U+qdZieRSSVBDZgiZ6w8gIMea6dLpMae7HMgYi1WOcfUt NVCgdcqbTfsKaRAkH1qcfhY4ZaNRWqFWMeWy0Nw5g8/BJlu8cssVh7ipv6ImdFZoQ7Vd dledinPIbpdW96p6LOYullIXH0peEOOl9++ii0Bzj6P11/mVZCT8baLEr5GVcWj0jZQb D3iuZYh7YyjFafCuwiWd632BYXUuMpoNxlqQ2cGXU5CeMpnqKWogzDTTvAH1G9DVdH87 /RZA== X-Gm-Message-State: ANhLgQ1PsUW2HKYz+w4l06E+0QDSFRiy2MXM4xWIoME/pJvhV1DMkRRK IXAFd2jCZlXyna4luJA3XqKO0miYeyg= X-Google-Smtp-Source: ADFU+vva5W4B1Hs196odl6rPQgxitTbKhrNEhXlYIDMLH0NYAZCChVaXkrV1ZiRp5NxeGjySFWxRzg== X-Received: by 2002:ac8:111a:: with SMTP id c26mr18014152qtj.249.1584892534468; Sun, 22 Mar 2020 08:55:34 -0700 (PDT) Received: from localhost.localdomain ([2804:1b2:8082:f225:59d4:a024:6301:5915]) by smtp.gmail.com with ESMTPSA id r40sm10297286qtc.39.2020.03.22.08.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Mar 2020 08:55:33 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Mar 2020 16:55:24 +0100 Message-Id: <20200322155525.23410-1-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegvideo_enc: fix multi-threaded motion estimation rounding for mpeg4 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Ramiro Polla MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ff_init_me() was being called after ff_update_duplicate_context(), which caused the propagation of the initialization to other thread contexts to be delayed by one frame. In the case of mpeg4 (or flipflop_rounding), this would make the hpel_put functions differ between the first thread (which would be correctly initialized) and the other threads (which would be stale from the previous frame). --- libavcodec/mpegvideo_enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index b2eb9cf318..8c2672f76a 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3699,6 +3699,9 @@ static int encode_picture(MpegEncContext *s, int picture_number) s->q_chroma_intra_matrix16 = s->q_intra_matrix16; } + if(ff_init_me(s)<0) + return -1; + s->mb_intra=0; //for the rate distortion & bit compare functions for(i=1; ithread_context[i], s); @@ -3706,9 +3709,6 @@ static int encode_picture(MpegEncContext *s, int picture_number) return ret; } - if(ff_init_me(s)<0) - return -1; - /* Estimate motion for every MB */ if(s->pict_type != AV_PICTURE_TYPE_I){ s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8;