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 3CFA0400DF for ; Fri, 13 Oct 2023 14:17:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D68DC68C856; Fri, 13 Oct 2023 17:17:05 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96D4768BEC2 for ; Fri, 13 Oct 2023 17:16:59 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F3F9F240498; Fri, 13 Oct 2023 16:16:58 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id lKcW3i5MTbHT; Fri, 13 Oct 2023 16:16:58 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 405F92400FF; Fri, 13 Oct 2023 16:16:58 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 95C7A1601B9; Fri, 13 Oct 2023 16:16:49 +0200 (CEST) From: Anton Khirnov To: "ffmpeg-devel@ffmpeg.org" In-Reply-To: References: <235b296cd67fed2c79862d4403dbe268d2f7e25b.camel@amazon.it> <75548e3c104400a6cef07dad2a75ffa648e830cc.camel@amazon.it> <169693528137.6638.10771778310430665651@lain.khirnov.net> Mail-Followup-To: "ffmpeg-devel@ffmpeg.org" , "Carotti, Elias" Date: Fri, 13 Oct 2023 16:16:49 +0200 Message-ID: <169720660959.32606.9316543522345619707@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] libavc/libx264: add support to propagate SSE values through encoder stats 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: "Carotti, Elias" 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: Quoting Carotti, Elias via ffmpeg-devel (2023-10-11 12:54:21) > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > index 77a9f173b4..85bd870f5d 100644 > --- a/libavcodec/libx264.c > +++ b/libavcodec/libx264.c > @@ -726,7 +726,39 @@ FF_ENABLE_DEPRECATION_WARNINGS > > pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe; > if (ret) { > - ff_side_data_set_encoder_stats(pkt, (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA, NULL, 0, pict_type); > + const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(csp_to_pixfmt(pic_out.img.i_csp)); There's a problem here - we do not handle all values of i_csp. E.g. we have no equivalent of X264_CSP_NV12 | X264_CSP_HIGH_DEPTH, which x264 will use for YUV420P10 input. The best solution is probably to use AVCodecContext.pix_fmt and assume that x264 doesn't do any nontrivial (i.e. other than interleaving and such) pixel format transformations internally. > + int error_count = 0; > + int64_t *errors = NULL; > + int64_t sse[3] = {0}; > + > + if (ctx->flags & AV_CODEC_FLAG_PSNR) { > + double scale[3] = { 1, > + (double)(1 << pix_desc->log2_chroma_h) * (1 << pix_desc->log2_chroma_w), > + (double)(1 << pix_desc->log2_chroma_h) * (1 << pix_desc->log2_chroma_w), > + }; > + > + error_count = pix_desc->nb_components; > + > + av_log(ctx, AV_LOG_DEBUG, "PSNR values from libx264: %.3f %.3f %.3f.\n", > + pic_out.prop.f_psnr[0], pic_out.prop.f_psnr[1], pic_out.prop.f_psnr[2]); In my tests libx264 prints these values by itself, so this seems redundant. -- Anton Khirnov _______________________________________________ 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".