From patchwork Sun Nov 27 17:03:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39502 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6960115pzb; Sun, 27 Nov 2022 09:07:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf65L11Dt5SSVw1flMPcXfeyMmrk+paGubpimEpPTMqa+DNyqR0D0cE+lypwB9dkbk2kApqZ X-Received: by 2002:a17:906:4e4e:b0:7ae:e6ac:2427 with SMTP id g14-20020a1709064e4e00b007aee6ac2427mr40131380ejw.345.1669568856318; Sun, 27 Nov 2022 09:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669568856; cv=none; d=google.com; s=arc-20160816; b=V8H9Bz71eJxvZgCceBHMjQQQYx6sc0TUUeTdqXnQMPKWyEXylHXSdNIH//wS77zbvH c2M2RB4RgCtBeny4UR1g6G6ziyYoUsMzW7GZFEe/7r9GVOfajhNjRavkLDBTXk76SLOG pL+8GyPW0xIPF3iBgwIu4qVAgEky2bdZ4Cm+FZ+PYgMaOXr9otodw5qf+noiP33hxdES yVLQxC/QMwQszVFpL8oE7f+Aug6KC1Ol4Krvr4BVnuo+pGIrKHkYCnphwON5Cm4wCMC6 yYY7zBVWRmQ1PcV9HCVIBgZTQYxvGcWQS8O+Yed1RBxVMuKx9ZwoPuTcRqzAvQf3t+Lf TusQ== 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:delivered-to; bh=nXMR5gU3PTaF4LljkD0+3Bz2om6vdL3tcNB09/H1ocw=; b=yLkqXY68QND6Fbk2m3ZCbkPJwb/mPfrxKTvCfTfN0v/BJUfxxfyw12BZHkbGePR8ww 3O9yKI8c/n+YMcDkgE7PHew2xAXK4mOMVGaMwoprrrK7Iwl+t7KMMLrakGJ856s7hbcz qP1WKhTzeGLpnLERfuIGPrBMbux+GWZvIj0BK1Z/5tVyUDnKFe92F7MfOPqNh1CmYUsW picKwLs+lcWdSTF3uOyO/IDbefufXfpPtZD9JcpETYlhhUrxh7qPlYgPxBYd8eMG8Ne6 YI105RflbN4K+1cJz/IcEGU95HYmUJgWaPJjPfQrbFJw24iehzZACKnA3aBx7pvg2cay zf4g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l16-20020a170906795000b0077bd074d50bsi9314920ejo.105.2022.11.27.09.07.35; Sun, 27 Nov 2022 09:07:36 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2687968BB98; Sun, 27 Nov 2022 19:06:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B75CA68B82B for ; Sun, 27 Nov 2022 19:05:59 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7A15C2405EC for ; Sun, 27 Nov 2022 18:05:59 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id bvxWS6R9JCxk for ; Sun, 27 Nov 2022 18:05:58 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C7BAF2406CE for ; Sun, 27 Nov 2022 18:05:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 38E743A25BE for ; Sun, 27 Nov 2022 18:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2022 18:03:31 +0100 Message-Id: <20221127170351.11477-10-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221127170351.11477-1-anton@khirnov.net> References: <20221127170351.11477-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/30] lavc/libx264: reindent after previous commit 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: EKrkOEVGgwLJ --- libavcodec/libx264.c | 94 ++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 342d07a829..1819809a48 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -338,13 +338,13 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth, { X264Context *x4 = ctx->priv_data; - int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE; - int mby = (frame->height + MB_SIZE - 1) / MB_SIZE; - int qp_range = 51 + 6 * (bit_depth - 8); - int nb_rois; - const AVRegionOfInterest *roi; - uint32_t roi_size; - float *qoffsets; + int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE; + int mby = (frame->height + MB_SIZE - 1) / MB_SIZE; + int qp_range = 51 + 6 * (bit_depth - 8); + int nb_rois; + const AVRegionOfInterest *roi; + uint32_t roi_size; + float *qoffsets; if (x4->params.rc.i_aq_mode == X264_AQ_NONE) { if (!x4->roi_warned) { @@ -360,48 +360,48 @@ static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth, return 0; } - roi = (const AVRegionOfInterest*)data; - roi_size = roi->self_size; - if (!roi_size || size % roi_size != 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n"); - return AVERROR(EINVAL); - } - nb_rois = size / roi_size; - - qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); - if (!qoffsets) - return AVERROR(ENOMEM); - - // This list must be iterated in reverse because the first - // region in the list applies when regions overlap. - for (int i = nb_rois - 1; i >= 0; i--) { - int startx, endx, starty, endy; - float qoffset; - - roi = (const AVRegionOfInterest*)(data + roi_size * i); - - starty = FFMIN(mby, roi->top / MB_SIZE); - endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE); - startx = FFMIN(mbx, roi->left / MB_SIZE); - endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE); - - if (roi->qoffset.den == 0) { - av_free(qoffsets); - av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n"); - return AVERROR(EINVAL); - } - qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den; - qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range); - - for (int y = starty; y < endy; y++) { - for (int x = startx; x < endx; x++) { - qoffsets[x + y*mbx] = qoffset; - } - } + roi = (const AVRegionOfInterest*)data; + roi_size = roi->self_size; + if (!roi_size || size % roi_size != 0) { + av_log(ctx, AV_LOG_ERROR, "Invalid AVRegionOfInterest.self_size.\n"); + return AVERROR(EINVAL); + } + nb_rois = size / roi_size; + + qoffsets = av_calloc(mbx * mby, sizeof(*qoffsets)); + if (!qoffsets) + return AVERROR(ENOMEM); + + // This list must be iterated in reverse because the first + // region in the list applies when regions overlap. + for (int i = nb_rois - 1; i >= 0; i--) { + int startx, endx, starty, endy; + float qoffset; + + roi = (const AVRegionOfInterest*)(data + roi_size * i); + + starty = FFMIN(mby, roi->top / MB_SIZE); + endy = FFMIN(mby, (roi->bottom + MB_SIZE - 1)/ MB_SIZE); + startx = FFMIN(mbx, roi->left / MB_SIZE); + endx = FFMIN(mbx, (roi->right + MB_SIZE - 1)/ MB_SIZE); + + if (roi->qoffset.den == 0) { + av_free(qoffsets); + av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.qoffset.den must not be zero.\n"); + return AVERROR(EINVAL); + } + qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den; + qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range); + + for (int y = starty; y < endy; y++) { + for (int x = startx; x < endx; x++) { + qoffsets[x + y*mbx] = qoffset; } + } + } - pic->prop.quant_offsets = qoffsets; - pic->prop.quant_offsets_free = av_free; + pic->prop.quant_offsets = qoffsets; + pic->prop.quant_offsets_free = av_free; return 0; }