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 1E9C9474A2 for ; Wed, 8 May 2024 15:20:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF14168D68E; Wed, 8 May 2024 18:20:02 +0300 (EEST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE7D668D669 for ; Wed, 8 May 2024 18:19:55 +0300 (EEST) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-34eb52bfca3so3244293f8f.0 for ; Wed, 08 May 2024 08:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715181594; x=1715786394; darn=ffmpeg.org; 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=nr/l8dNYNFAnUZjY3bLiS541Avw5ugz69CK55Xy432I=; b=Krsrm+BYSDRwJIdmhEU8YPvoIyMSJkRfNVPIjsqGkDsJ2AUlRHA9tDQBDBRCWS8v/D hV+UjjnkbbvJ+ewE5ujmihQVzpwxRjnE1o1yf3Yoeeby0tL4BRTs8vn6QRGP1IBbLD7I 6nC/kGY1KYcl6xvhYl325EmH4VbhtuhocW+Q95dA3sU1Ape22K61a4EWw50xSZ4uRU0t RYJu2zfkLc7OvrmrJiRcq9UL6Dw8x6fUqutQPHIgNKfefHcLHkUAsONIBMI5aXEO9HKE dVkf0obWL91Ht95zk2jLnoBQVWDr4ShG1zlv/z8SpOyuZo3SI3dxNJr6FkVO/5ZHocee hcDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715181594; x=1715786394; 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=nr/l8dNYNFAnUZjY3bLiS541Avw5ugz69CK55Xy432I=; b=PrMHdzRZCbItJo5AjU/2lsbNxgYQGHaeTPESvG0ta3YsVEC2z8IVCFeSX//6eAMA4n E0ioUkGlfD7OQ3ifegUUjXw2tpSBfA0h37xXL8b03OPCmvkGdfdfxS9nSIrASNa5ZKfo w/N1vU09+ckGvDHSZNA6f5MMCsclVIky2QX2oKIN4Eukf6Pkp9bZUpfNOHk5H2n128NL 80D5OTE3OwD7sx0c8lqkZ7WMw0H6aJZtC6KOq14/xe8ERyQB1Dj9vHp7vP18+dys2cgg bO7KVg/uY6i5p6gYLQvEf+Xf9Z8yUEWZA1UtdAlCcUCKnZnRUdM/heBGmmqnZoLZ9aFT KK5g== X-Gm-Message-State: AOJu0YweYAwjmKXkCs+nJXRRhc0B1vugySVQFJMaclDwMeaDkBOECOEy KVNCFO8ub3EqnVg4OEuhdCKaBB4kGOohgg2mk3xtXjHjSgaFl4e/NmgzNp+M X-Google-Smtp-Source: AGHT+IGx67oGHpKFgX4qS4MgCy9QKXklExvWOzaI30Gmo6en2nw9bBXItaefN/KA4do4JrojyROPeg== X-Received: by 2002:a5d:4533:0:b0:34c:72aa:6fe0 with SMTP id ffacd0b85a97d-34fca241368mr2716937f8f.18.1715181594382; Wed, 08 May 2024 08:19:54 -0700 (PDT) Received: from localhost.localdomain ([87.66.43.239]) by smtp.gmail.com with ESMTPSA id o9-20020a5d47c9000000b0034d7a555047sm15562105wrc.96.2024.05.08.08.19.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:19:53 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 May 2024 17:19:50 +0200 Message-Id: <20240508151950.28555-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240508151950.28555-1-ramiro.polla@gmail.com> References: <20240508151950.28555-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] libavcodec/motion_est: fix penalty_factor for b frames 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: In direct_search() and ff_estimate_b_frame_motion(), penalty_factor would be used before being initialized in estimate_motion_b(). Also, the initialization would happen more than once unnecessarily. --- libavcodec/motion_est.c | 15 ++++++++------- tests/ref/vsynth/vsynth1-mpeg4-thread | 6 +++--- tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd | 6 +++--- tests/ref/vsynth/vsynth2-mpeg4-adap | 8 ++++---- tests/ref/vsynth/vsynth2-mpeg4-qprd | 6 +++--- tests/ref/vsynth/vsynth2-mpeg4-thread | 6 +++--- tests/ref/vsynth/vsynth_lena-mpeg4-rc | 4 ++-- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index df9d1befa8..fb569ede8a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1127,9 +1127,6 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, const uint8_t * const mv_penalty = c->mv_penalty[f_code] + MAX_DMV; int mv_scale; - c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); - c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp); - c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp); c->current_mv_penalty= mv_penalty; get_limits(s, 16*mb_x, 16*mb_y); @@ -1495,7 +1492,6 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; - const int penalty_factor= c->mb_penalty_factor; int fmin, bmin, dmin, fbmin, bimin, fimin; int type=0; const int xy = mb_y*s->mb_stride + mb_x; @@ -1517,22 +1513,27 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, return; } + c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp); + c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp); + c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp); + if (s->codec_id == AV_CODEC_ID_MPEG4) dmin= direct_search(s, mb_x, mb_y); else dmin= INT_MAX; + // FIXME penalty stuff for non-MPEG-4 c->skip=0; fmin = estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code) + - 3 * penalty_factor; + 3 * c->mb_penalty_factor; c->skip=0; bmin = estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code) + - 2 * penalty_factor; + 2 * c->mb_penalty_factor; ff_dlog(s, " %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]); c->skip=0; - fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor; + fbmin= bidir_refine(s, mb_x, mb_y) + c->mb_penalty_factor; ff_dlog(s, "%d %d %d %d\n", dmin, fmin, bmin, fbmin); if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { diff --git a/tests/ref/vsynth/vsynth1-mpeg4-thread b/tests/ref/vsynth/vsynth1-mpeg4-thread index 6b69fb4c12..6b110c49fb 100644 --- a/tests/ref/vsynth/vsynth1-mpeg4-thread +++ b/tests/ref/vsynth/vsynth1-mpeg4-thread @@ -1,4 +1,4 @@ -369ace2f9613261af869efd9fbb3c149 *tests/data/fate/vsynth1-mpeg4-thread.avi -774754 tests/data/fate/vsynth1-mpeg4-thread.avi -9aa327a244d5179acf7fe64dc1459bff *tests/data/fate/vsynth1-mpeg4-thread.out.rawvideo +7761391e354266976a9e0155eff983dd *tests/data/fate/vsynth1-mpeg4-thread.avi +774752 tests/data/fate/vsynth1-mpeg4-thread.avi +bbdbe9af4f5b106b847595bf3040699f *tests/data/fate/vsynth1-mpeg4-thread.out.rawvideo stddev: 10.13 PSNR: 28.02 MAXDIFF: 183 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd b/tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd index 16de39edfc..f5bbecfcb2 100644 --- a/tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd +++ b/tests/ref/vsynth/vsynth2-mpeg2-ivlc-qprd @@ -1,4 +1,4 @@ -907a30295ed8323780eee08e606af0ab *tests/data/fate/vsynth2-mpeg2-ivlc-qprd.mpeg2video -269722 tests/data/fate/vsynth2-mpeg2-ivlc-qprd.mpeg2video -d2d9793bf8f3427b5cc17a1be78ddd64 *tests/data/fate/vsynth2-mpeg2-ivlc-qprd.out.rawvideo +f612ea89aa79a7f7b93a8acf332705c4 *tests/data/fate/vsynth2-mpeg2-ivlc-qprd.mpeg2video +269723 tests/data/fate/vsynth2-mpeg2-ivlc-qprd.mpeg2video +88e17886e6383755829d7da519fd5e79 *tests/data/fate/vsynth2-mpeg2-ivlc-qprd.out.rawvideo stddev: 5.54 PSNR: 33.25 MAXDIFF: 94 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-mpeg4-adap b/tests/ref/vsynth/vsynth2-mpeg4-adap index 35b2b6aac9..e058cd1ce3 100644 --- a/tests/ref/vsynth/vsynth2-mpeg4-adap +++ b/tests/ref/vsynth/vsynth2-mpeg4-adap @@ -1,4 +1,4 @@ -06a397fe43dab7b6cf56870410fbbbaf *tests/data/fate/vsynth2-mpeg4-adap.avi -203000 tests/data/fate/vsynth2-mpeg4-adap.avi -686565d42d8ba5aea790824b04fa0a18 *tests/data/fate/vsynth2-mpeg4-adap.out.rawvideo -stddev: 4.55 PSNR: 34.95 MAXDIFF: 84 bytes: 7603200/ 7603200 +9465ef120d560537d8fcfb5564782e01 *tests/data/fate/vsynth2-mpeg4-adap.avi +203004 tests/data/fate/vsynth2-mpeg4-adap.avi +d7851ab1ca9744f8e618a24193e5ef76 *tests/data/fate/vsynth2-mpeg4-adap.out.rawvideo +stddev: 4.56 PSNR: 34.95 MAXDIFF: 84 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-mpeg4-qprd b/tests/ref/vsynth/vsynth2-mpeg4-qprd index 0a8786b89a..3face947c2 100644 --- a/tests/ref/vsynth/vsynth2-mpeg4-qprd +++ b/tests/ref/vsynth/vsynth2-mpeg4-qprd @@ -1,4 +1,4 @@ -4ddd2fef35854d9b387bbcbda03dc7f0 *tests/data/fate/vsynth2-mpeg4-qprd.avi -248706 tests/data/fate/vsynth2-mpeg4-qprd.avi -baa8d0d57a7fb5e393642cb20efed2c2 *tests/data/fate/vsynth2-mpeg4-qprd.out.rawvideo +33fc3d5507cc8d2c8b63b8f811e62e4c *tests/data/fate/vsynth2-mpeg4-qprd.avi +248734 tests/data/fate/vsynth2-mpeg4-qprd.avi +61f8006e8903915056493fb1f05d1b2f *tests/data/fate/vsynth2-mpeg4-qprd.out.rawvideo stddev: 4.85 PSNR: 34.40 MAXDIFF: 85 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-mpeg4-thread b/tests/ref/vsynth/vsynth2-mpeg4-thread index 49c0ce0241..a1791c49ec 100644 --- a/tests/ref/vsynth/vsynth2-mpeg4-thread +++ b/tests/ref/vsynth/vsynth2-mpeg4-thread @@ -1,4 +1,4 @@ -92128f8adc4ac70a66fdddf58e46b923 *tests/data/fate/vsynth2-mpeg4-thread.avi -268396 tests/data/fate/vsynth2-mpeg4-thread.avi -f432bd8d897c7c8e286e385b77cedcfa *tests/data/fate/vsynth2-mpeg4-thread.out.rawvideo +44df605055498a01afb53eaaabdb94b4 *tests/data/fate/vsynth2-mpeg4-thread.avi +268394 tests/data/fate/vsynth2-mpeg4-thread.avi +13240eaccc345bf4b45f24d44cfc5ca2 *tests/data/fate/vsynth2-mpeg4-thread.out.rawvideo stddev: 4.89 PSNR: 34.34 MAXDIFF: 86 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth_lena-mpeg4-rc b/tests/ref/vsynth/vsynth_lena-mpeg4-rc index fd6a998046..a21ddc87e3 100644 --- a/tests/ref/vsynth/vsynth_lena-mpeg4-rc +++ b/tests/ref/vsynth/vsynth_lena-mpeg4-rc @@ -1,4 +1,4 @@ -396a76466dee56e2714dfa42cebe3d2d *tests/data/fate/vsynth_lena-mpeg4-rc.avi +3ae5a2590bdd0e80a95bf374b06c553f *tests/data/fate/vsynth_lena-mpeg4-rc.avi 226314 tests/data/fate/vsynth_lena-mpeg4-rc.avi -6e8b62e8c3bcbfdcc58afb69a0b1c4e3 *tests/data/fate/vsynth_lena-mpeg4-rc.out.rawvideo +27c8771df4154f2be317465a3d3cbd56 *tests/data/fate/vsynth_lena-mpeg4-rc.out.rawvideo stddev: 4.23 PSNR: 35.60 MAXDIFF: 85 bytes: 7603200/ 7603200 -- 2.30.2 _______________________________________________ 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".